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/+/3828794
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
changes/94/3828794/3
Josip Sokcevic 3 years ago committed by LUCI CQ
parent f9fede5f84
commit 940cd8e20f

@ -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'

Loading…
Cancel
Save