]> code.ossystems Code Review - openembedded-core.git/commit
devtool: categorise and order subcommands in help output
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Fri, 19 Feb 2016 09:38:53 +0000 (22:38 +1300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 21 Feb 2016 09:32:00 +0000 (09:32 +0000)
commite1b9d31e6ea3c254ecfe940fe795af44761e0e69
tree57d7be1ca898a2707a0919aea780bd2bb1bc070e
parent391b9ba30d802ac420ddf382588e03e718861c01
devtool: categorise and order subcommands in help output

The listing of subcommands in the --help output for devtool was starting
to get difficult to follow, with commands appearing in no particular
order (due to some being in separate modules and the order of those
modules being parsed). Logically grouping the subcommands as well as
being able to exercise some control over the order of the subcommands
and groups would help, if we do so without losing the dynamic nature of
the list (i.e. that it comes from the plugins). Argparse provides no
built-in way to handle this and really, really makes it a pain to add,
but with some subclassing and hacking it's now possible, and can be
extended by any plugin as desired.

To put a subcommand into a group, all you need to do is specify a group=
parameter in the call to subparsers.add_parser(). you can also specify
an order= parameter to make the subcommand sort higher or lower in the
list (higher order numbers appear first, so use negative numbers to
force items to the end if that's what you want). To add a new group, use
subparsers.add_subparser_group(), supplying the name, description and
optionally an order number for the group itself (again, higher numbers
appear first).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
12 files changed:
scripts/devtool
scripts/lib/argparse_oe.py
scripts/lib/devtool/build-image.py
scripts/lib/devtool/build.py
scripts/lib/devtool/deploy.py
scripts/lib/devtool/package.py
scripts/lib/devtool/runqemu.py
scripts/lib/devtool/sdk.py
scripts/lib/devtool/search.py
scripts/lib/devtool/standard.py
scripts/lib/devtool/upgrade.py
scripts/lib/devtool/utilcmds.py