gecko-dev/python/mach
Andrew Halberstadt b8511feb50 Bug 1391675 - [mach] Allow commands to have both a parser and subcommands, r=gps
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
2017-08-17 11:10:48 -04:00
..
docs Bug 1255450 - mach settings documentation fix, DONTBUILD, r=me 2016-04-12 21:03:36 -04:00
mach Bug 1391675 - [mach] Allow commands to have both a parser and subcommands, r=gps 2017-08-17 11:10:48 -04:00
README.rst Bug 1108399 - Move mach docs into sphinx; r=ahal 2014-12-07 10:40:19 -08:00
bash-completion.sh Bug 950957 - Use ${COMP_WORDS[0]} for completion in mach. r=gps 2013-12-19 11:42:19 -05:00
setup.py NO BUG - Bump version of mach to 0.6 2016-05-02 13:36:33 -07:00

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/``.