From 11d8093fc8538379e1e693e6bd4ba1cacdf10839 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Tue, 26 Apr 2016 12:21:47 -0700 Subject: [PATCH] Support combination of shorthand flag and equal sign for host option Signed-off-by: Joffrey F --- compose/cli/command.py | 5 ++++- tests/acceptance/cli_test.py | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/compose/cli/command.py b/compose/cli/command.py index b7160deec..8ac3aff4f 100644 --- a/compose/cli/command.py +++ b/compose/cli/command.py @@ -21,12 +21,15 @@ log = logging.getLogger(__name__) def project_from_options(project_dir, options): environment = Environment.from_env_file(project_dir) + host = options.get('--host') + if host is not None: + host = host.lstrip('=') return get_project( project_dir, get_config_path_from_options(project_dir, options, environment), project_name=options.get('--project-name'), verbose=options.get('--verbose'), - host=options.get('--host'), + host=host, tls_config=tls_config_from_options(options), environment=environment ) diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 862a54f29..1a4f9f53b 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -145,6 +145,13 @@ class CLITestCase(DockerClientTestCase): # Prevent tearDown from trying to create a project self.base_dir = None + def test_shorthand_host_opt(self): + self.dispatch( + ['-H={0}'.format(os.environ.get('DOCKER_HOST', 'unix://')), + 'up', '-d'], + returncode=0 + ) + def test_config_list_services(self): self.base_dir = 'tests/fixtures/v2-full' result = self.dispatch(['config', '--services'])