mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-30 14:17:36 -10:00
We currently raise if we detect a command has both the `parser` attribute and a subcommand at the same time, but as far as I can tell, there's no good reason to do this. Handling a parser + subcommands seems to work exactly how you would expect. Furthermore, it isn't an error to have subcommands + @CommandArgument, so it doesn't make sense that we're allowing one but not the other. This change solves an (admittedly unique) use case I'm trying to build into |mach try|. There are N subcommands that all support a --save and --load style argument. So, e.g, we might have: ./mach try syntax --save foo ./mach try fuzzy --save bar The main command will have the ability to detect which subcommand a saved value was generated from and automatically dispatch to it. So this will work: ./mach try --load foo # dispatches to the syntax subcommand ./mach try --load bar # dispatches to the fuzzy subcommand In order to share the --save/--load arguments across the main command + subcommands, we need to set the parser attribute. MozReview-Commit-ID: KmXRj8TBvYK
==== mach ==== Mach (German for *do*) is a generic command dispatcher for the command line. To use mach, you install the mach core (a Python package), create an executable *driver* script (named whatever you want), and write mach commands. When the *driver* is executed, mach dispatches to the requested command handler automatically. To learn more, read the docs in ``docs/``.