mirror of
https://git.yoctoproject.org/poky
synced 2026-04-30 21:32:13 +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
@@ -296,10 +296,16 @@ def sdk_install(args, config, basepath, workspace):
|
||||
def register_commands(subparsers, context):
|
||||
"""Register devtool subcommands from the sdk plugin"""
|
||||
if context.fixed_setup:
|
||||
parser_sdk = subparsers.add_parser('sdk-update', help='Update SDK components from a nominated location')
|
||||
parser_sdk = subparsers.add_parser('sdk-update',
|
||||
help='Update SDK components from a nominated location',
|
||||
group='sdk')
|
||||
parser_sdk.add_argument('updateserver', help='The update server to fetch latest SDK components from', nargs='?')
|
||||
parser_sdk.add_argument('--skip-prepare', action="store_true", help='Skip re-preparing the build system after updating (for debugging only)')
|
||||
parser_sdk.set_defaults(func=sdk_update)
|
||||
parser_sdk_install = subparsers.add_parser('sdk-install', help='Install additional SDK components', description='Installs additional recipe development files into the SDK. (You can use "devtool search" to find available recipes.)')
|
||||
|
||||
parser_sdk_install = subparsers.add_parser('sdk-install',
|
||||
help='Install additional SDK components',
|
||||
description='Installs additional recipe development files into the SDK. (You can use "devtool search" to find available recipes.)',
|
||||
group='sdk')
|
||||
parser_sdk_install.add_argument('recipename', help='Name of the recipe to install the development artifacts for', nargs='+')
|
||||
parser_sdk_install.set_defaults(func=sdk_install)
|
||||
|
||||
Reference in New Issue
Block a user