mirror of
https://git.yoctoproject.org/poky
synced 2026-04-23 09:32:17 +02:00
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). (From OE-Core rev: e1b9d31e6ea3c254ecfe940fe795af44761e0e69) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
9f7df76eb4
commit
32ef523898
@@ -214,7 +214,8 @@ The ./configure %s output for %s follows.
|
||||
def register_commands(subparsers, context):
|
||||
"""Register devtool subcommands from this plugin"""
|
||||
parser_edit_recipe = subparsers.add_parser('edit-recipe', help='Edit a recipe file in your workspace',
|
||||
description='Runs the default editor (as specified by the EDITOR variable) on the specified recipe. Note that the recipe file itself must be in the workspace (i.e. as a result of "devtool add" or "devtool upgrade"); you can override this with the -a/--any-recipe option.')
|
||||
description='Runs the default editor (as specified by the EDITOR variable) on the specified recipe. Note that the recipe file itself must be in the workspace (i.e. as a result of "devtool add" or "devtool upgrade"); you can override this with the -a/--any-recipe option.',
|
||||
group='working')
|
||||
parser_edit_recipe.add_argument('recipename', help='Recipe to edit')
|
||||
parser_edit_recipe.add_argument('--any-recipe', '-a', action="store_true", help='Edit any recipe, not just where the recipe file itself is in the workspace')
|
||||
parser_edit_recipe.set_defaults(func=edit_recipe)
|
||||
@@ -223,7 +224,8 @@ def register_commands(subparsers, context):
|
||||
# gets the order wrong - recipename must come before --arg
|
||||
parser_configure_help = subparsers.add_parser('configure-help', help='Get help on configure script options',
|
||||
usage='devtool configure-help [options] recipename [--arg ...]',
|
||||
description='Displays the help for the configure script for the specified recipe (i.e. runs ./configure --help) prefaced by a header describing the current options being specified. Output is piped through less (or whatever PAGER is set to, if set) for easy browsing.')
|
||||
description='Displays the help for the configure script for the specified recipe (i.e. runs ./configure --help) prefaced by a header describing the current options being specified. Output is piped through less (or whatever PAGER is set to, if set) for easy browsing.',
|
||||
group='working')
|
||||
parser_configure_help.add_argument('recipename', help='Recipe to show configure help for')
|
||||
parser_configure_help.add_argument('-p', '--no-pager', help='Disable paged output', action="store_true")
|
||||
parser_configure_help.add_argument('-n', '--no-header', help='Disable explanatory header text', action="store_true")
|
||||
|
||||
Reference in New Issue
Block a user