Revert "gclient: return non-zero exit code on unknown command"
This reverts commit 2c199e1ec4a226ccecb5282879f284965c5c9b39.
Reason for revert: This makes calls to gclient that have the only intention of updating gclient fail, like:
https://cs.chromium.org/chromium/src/v8/tools/try_perf.py?l=93
Reverting for now to give time to clean up such scripts before reland.
Original change's description:
> gclient: return non-zero exit code on unknown command
>
> Bug: none
> Change-Id: I447f66765679b7b66b5748af1cf1f501610603bf
> Reviewed-on: https://chromium-review.googlesource.com/504408
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
>
TBR=iannucci@chromium.org,phajdan.jr@chromium.org,dpranke@chromium.org,tandrii@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Bug: none
Change-Id: I9496f7192dfde1e38c186a94ac985190b76b2438
Reviewed-on: https://chromium-review.googlesource.com/506563
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
diff --git a/subcommand.py b/subcommand.py
index ae0705b..a9ebae0 100644
--- a/subcommand.py
+++ b/subcommand.py
@@ -66,8 +66,13 @@
def CMDhelp(parser, args):
"""Prints list of commands or help for a specific command."""
- parser.print_help()
- return 0
+ # This is the default help implementation. It can be disabled or overriden if
+ # wanted.
+ if not any(i in ('-h', '--help') for i in args):
+ args = args + ['--help']
+ _, args = parser.parse_args(args)
+ # Never gets there.
+ assert False
def _get_color_module():
@@ -250,9 +255,7 @@
if cmdhelp:
# Not a known command. Default to help.
self._add_command_usage(parser, cmdhelp)
- # Make sure we return a non-zero exit code for unknown commands.
- rc = cmdhelp(parser, args)
- return rc if rc != 0 else 2
+ return cmdhelp(parser, args)
# Nothing can be done.
return 2