From 782a46fd6074ecabcd8bf65b126bfa39e6ca90bc Mon Sep 17 00:00:00 2001 From: "Michael A. Smith" Date: Sat, 1 Nov 2014 19:22:22 -0400 Subject: [PATCH] Fixes #602 Allowing `help $cmd` with no figfile Signed-off-by: Michael A. Smith --- fig/cli/command.py | 5 +++++ tests/fixtures/no-figfile/.gitignore | 0 tests/integration/cli_test.py | 10 ++++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/fixtures/no-figfile/.gitignore diff --git a/fig/cli/command.py b/fig/cli/command.py index 743c96e930..1601f94a24 100644 --- a/fig/cli/command.py +++ b/fig/cli/command.py @@ -42,6 +42,11 @@ class Command(DocoptCommand): raise errors.ConnectionErrorGeneric(self.get_client().base_url) def perform_command(self, options, handler, command_options): + if options['COMMAND'] == 'help': + # Skip looking up the figfile. + handler(None, command_options) + return + explicit_config_path = options.get('--file') or os.environ.get('FIG_FILE') project = self.get_project( self.get_config_path(explicit_config_path), diff --git a/tests/fixtures/no-figfile/.gitignore b/tests/fixtures/no-figfile/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/cli_test.py b/tests/integration/cli_test.py index 0581e8b141..ceb93f62bc 100644 --- a/tests/integration/cli_test.py +++ b/tests/integration/cli_test.py @@ -25,6 +25,16 @@ class CLITestCase(DockerClientTestCase): def project(self): return self.command.get_project(self.command.get_config_path()) + def test_help(self): + old_base_dir = self.command.base_dir + self.command.base_dir = 'tests/fixtures/no-figfile' + with self.assertRaises(SystemExit) as exc_context: + self.command.dispatch(['help', 'up'], None) + self.assertIn('Usage: up [options] [SERVICE...]', str(exc_context.exception)) + # self.project.kill() fails during teardown + # unless there is a figfile. + self.command.base_dir = old_base_dir + @patch('sys.stdout', new_callable=StringIO) def test_ps(self, mock_stdout): self.project.get_service('simple').create_container()