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>
diff --git a/subcommand.py b/subcommand.py
index a9ebae0..ae0705b 100644
--- a/subcommand.py
+++ b/subcommand.py
@@ -66,13 +66,8 @@
 
 def CMDhelp(parser, args):
   """Prints list of commands or help for a specific command."""
-  # 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
+  parser.print_help()
+  return 0
 
 
 def _get_color_module():
@@ -255,7 +250,9 @@
     if cmdhelp:
       # Not a known command. Default to help.
       self._add_command_usage(parser, cmdhelp)
-      return cmdhelp(parser, args)
+      # Make sure we return a non-zero exit code for unknown commands.
+      rc = cmdhelp(parser, args)
+      return rc if rc != 0 else 2
 
     # Nothing can be done.
     return 2