Commit 940cd8e2 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Use empty argument list in cmdhelp

If a wrong command name is used (e.g. typo), cmdhelp is triggered.
However, if user specifies any additional arguments (other than -h),
then user is presented with not so useful message.

This CL calls cmdhelp with no arguments.

Fixed: 1352093
Change-Id: I30c0b5f580f18b4fa2cb59d3195b67bb083f3442
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3828794Reviewed-by: 's avatarAravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent f9fede5f
......@@ -255,7 +255,9 @@ class CommandDispatcher(object):
if cmdhelp:
# Not a known command. Default to help.
self._add_command_usage(parser, cmdhelp)
return cmdhelp(parser, args)
# Don't pass list of arguments as those may not be supported by cmdhelp.
# See: https://crbug.com/1352093
return cmdhelp(parser, [])
# Nothing can be done.
return 2
......@@ -139,7 +139,7 @@ class SubcommandTest(unittest.TestCase):
self._setUpTestCommands()
self.assertEqual(0, self.sc.execute(self.parser, ['not-found']))
self.module.CMDhelp.assert_called_once_with(self.parser, ['not-found'])
self.module.CMDhelp.assert_called_once_with(self.parser, [])
self.assertEqual(
'Module documentation\n\n'
'Commands are:\n'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment