Bug 1262495 - [mach] Allow running root commands that have subcommands on their own, r?gps draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 06 Apr 2016 11:41:13 -0400
changeset 348076 f4d562358f35db86ab1cf425aa3dd35fe5fcdee1
parent 348040 68c0b7d6f16ce5bb023e08050102b5f2fe4aacd8
child 348077 e3889e6036ef6d5de1a4cf69c772527ad9441a33
push id14744
push userahalberstadt@mozilla.com
push dateWed, 06 Apr 2016 15:44:19 +0000
reviewersgps
bugs1262495
milestone48.0a1
Bug 1262495 - [mach] Allow running root commands that have subcommands on their own, r?gps For example, say there is a command 'foo' that has a subcommand 'bar'. Prior to this, it was not possible to run: ./mach foo as its own independent command. The above would instead print the subcommand help for 'bar'. MozReview-Commit-ID: JU4dXoxnCyu
python/mach/mach/dispatcher.py
--- a/python/mach/mach/dispatcher.py
+++ b/python/mach/mach/dispatcher.py
@@ -135,21 +135,18 @@ class CommandAction(argparse.Action):
         handler = self._mach_registrar.command_handlers.get(command)
 
         usage = '%(prog)s [global arguments] ' + command + \
             ' [command arguments]'
 
         subcommand = None
 
         # If there are sub-commands, parse the intent out immediately.
-        if handler.subcommand_handlers:
-            if not args:
-                self._handle_subcommand_main_help(parser, handler)
-                sys.exit(0)
-            elif len(args) == 1 and args[0] in ('help', '--help'):
+        if handler.subcommand_handlers and args:
+            if len(args) == 1 and args[0] in ('help', '--help'):
                 self._handle_subcommand_main_help(parser, handler)
                 sys.exit(0)
             # mach <command> help <subcommand>
             elif len(args) == 2 and args[0] == 'help':
                 subcommand = args[1]
                 subhandler = handler.subcommand_handlers[subcommand]
                 self._handle_subcommand_help(parser, command, subcommand, subhandler)
                 sys.exit(0)