Bug 1255470 - [mach] don't raise if a subcommand exists and but wasn't found in args, r=gps
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 10 Mar 2016 11:51:43 -0500
changeset 288354 5c9c719705b1cdf7dd0cb9ec142e15764551f093
parent 288353 256bbc9c278e0891f66466038f3c0902cfb48da8
child 288355 70cc89f753aeebb88f2617ab22b1e265ea587b35
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1255470
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1255470 - [mach] don't raise if a subcommand exists and but wasn't found in args, r=gps This is currently preventing a command from having both args and subcommands at the same time. MozReview-Commit-ID: 66frAqamGjv
python/mach/mach/dispatcher.py
--- a/python/mach/mach/dispatcher.py
+++ b/python/mach/mach/dispatcher.py
@@ -149,27 +149,18 @@ class CommandAction(argparse.Action):
                 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)
             # We are running a sub command.
-            else:
+            elif args[0] in handler.subcommand_handlers:
                 subcommand = args[0]
-                if subcommand[0] == '-':
-                    raise MachError('%s invoked improperly. A sub-command name '
-                        'must be the first argument after the command name.' %
-                        command)
-
-                if subcommand not in handler.subcommand_handlers:
-                    raise UnknownCommandError(subcommand, 'run',
-                        handler.subcommand_handlers.keys())
-
                 handler = handler.subcommand_handlers[subcommand]
                 usage = '%(prog)s [global arguments] ' + command + ' ' + \
                     subcommand + ' [command arguments]'
                 args.pop(0)
 
         # We create a new parser, populate it with the command's arguments,
         # then feed all remaining arguments to it, merging the results
         # with ourselves. This is essentially what argparse subparsers