зеркало из https://github.com/mozilla/gecko-dev.git
b8511feb50
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 --HG-- extra : rebase_source : cbf1e402a080913709a34430274ae3191821dd72 |
||
---|---|---|
.. | ||
docs | ||
mach | ||
README.rst | ||
bash-completion.sh | ||
setup.py |
README.rst
==== 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/``.