summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--heatclient/shell.py2
-rw-r--r--heatclient/tests/test_shell.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/heatclient/shell.py b/heatclient/shell.py
index 4e5444a..b1ee0a9 100644
--- a/heatclient/shell.py
+++ b/heatclient/shell.py
@@ -295,7 +295,7 @@ class HeatShell(object):
# Handle top-level --help/-h before attempting to parse
# a command off the command line
- if options.help or not argv:
+ if not args and options.help or not argv:
self.do_help(options)
return 0
diff --git a/heatclient/tests/test_shell.py b/heatclient/tests/test_shell.py
index 09d114f..cd33c1b 100644
--- a/heatclient/tests/test_shell.py
+++ b/heatclient/tests/test_shell.py
@@ -244,6 +244,7 @@ class ShellBase(TestCase):
sys.stdout = six.StringIO()
_shell = heatclient.shell.HeatShell()
_shell.main(argstr.split())
+ self.subcommands = _shell.subcommands.keys()
except SystemExit:
exc_type, exc_value, exc_traceback = sys.exc_info()
self.assertEqual(0, exc_value.code)
@@ -273,6 +274,18 @@ class ShellTestCommon(ShellBase):
for r in required:
self.assertRegexpMatches(help_text, r)
+ def test_command_help(self):
+ output = self.shell('help help')
+ self.assertIn('usage: heat help [<subcommand>]', output)
+ subcommands = list(self.subcommands)
+ for command in subcommands:
+ if command.replace('_', '-') == 'bash-completion':
+ continue
+ output1 = self.shell('help %s' % command)
+ output2 = self.shell('%s --help' % command)
+ self.assertEqual(output1, output2)
+ self.assertRegexpMatches(output1, '^usage: heat %s' % command)
+
def test_debug_switch_raises_error(self):
fakes.script_keystone_client()
http.HTTPClient.json_request(