tsuru: import code from cmd/tsuru-base

Related to tsuru/tsuru#945.