Add command for Docker-style version information

This adds a command 'version' to show software versions information
like Docker does. In addition it includes:
- version of the docker-py-package
- Python-implementation and -version

Signed-off-by: Frank Sachsenheim <funkyfuture@riseup.net>
This commit is contained in:
funkyfuture 2015-01-25 00:16:37 +01:00 • committed by Frank Sachsenheim
commit ae9d619d86
3 changed files with 35 additions and 6 deletions

View file

@ -10,8 +10,7 @@ import sys
from docker.errors import APIError
import dockerpty
from .. import __version__
from .. import legacy
from .. import __version__, legacy
from ..project import NoSuchService, ConfigurationError
from ..service import BuildError, CannotBeScaledError, NeedsBuildError
from ..config import parse_environment
@ -20,7 +19,7 @@ from .docopt_command import NoSuchCommand
from .errors import UserError
from .formatter import Formatter
from .log_printer import LogPrinter
from .utils import yesno
from .utils import yesno, get_version_info
log = logging.getLogger(__name__)
@ -100,11 +99,12 @@ class TopLevelCommand(Command):
stop Stop services
up Create and start containers
migrate-to-labels Recreate containers to add labels
version Show the Docker-Compose version information
"""
def docopt_options(self):
options = super(TopLevelCommand, self).docopt_options()
options['version'] = "docker-compose %s" % __version__
options['version'] = get_version_info('compose')
return options
def build(self, project, options):
@ -497,6 +497,20 @@ class TopLevelCommand(Command):
"""
legacy.migrate_project_to_labels(project)
def version(self, project, options):
"""
Show version informations
Usage: version [--short]
Options:
--short Shows only Compose's version number.
"""
if options['--short']:
print(__version__)
else:
print(get_version_info('full'))
def list_containers(containers):
return ", ".join(c.name for c in containers)