summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/standard.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-02-19 22:38:53 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-21 09:32:42 +0000
commit32ef52389833a8b8dfb63444ace6561bb0ac741c (patch)
tree59f597df4ce685609706c7db90ee0eb654b044a5 /scripts/lib/devtool/standard.py
parent9f7df76eb49eac1ec7627061a8219e5d0b052034 (diff)
downloadpoky-32ef52389833a8b8dfb63444ace6561bb0ac741c.tar.gz
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>
Diffstat (limited to 'scripts/lib/devtool/standard.py')
-rw-r--r--scripts/lib/devtool/standard.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 804c127848..084039a855 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1303,7 +1303,8 @@ def register_commands(subparsers, context):
1303 1303
1304 defsrctree = get_default_srctree(context.config) 1304 defsrctree = get_default_srctree(context.config)
1305 parser_add = subparsers.add_parser('add', help='Add a new recipe', 1305 parser_add = subparsers.add_parser('add', help='Add a new recipe',
1306 description='Adds a new recipe to the workspace to build a specified source tree. Can optionally fetch a remote URI and unpack it to create the source tree.') 1306 description='Adds a new recipe to the workspace to build a specified source tree. Can optionally fetch a remote URI and unpack it to create the source tree.',
1307 group='starting', order=100)
1307 parser_add.add_argument('recipename', nargs='?', help='Name for new recipe to add (just name - no version, path or extension). If not specified, will attempt to auto-detect it.') 1308 parser_add.add_argument('recipename', nargs='?', help='Name for new recipe to add (just name - no version, path or extension). If not specified, will attempt to auto-detect it.')
1308 parser_add.add_argument('srctree', nargs='?', help='Path to external source tree. If not specified, a subdirectory of %s will be used.' % defsrctree) 1309 parser_add.add_argument('srctree', nargs='?', help='Path to external source tree. If not specified, a subdirectory of %s will be used.' % defsrctree)
1309 parser_add.add_argument('fetchuri', nargs='?', help='Fetch the specified URI and extract it to create the source tree') 1310 parser_add.add_argument('fetchuri', nargs='?', help='Fetch the specified URI and extract it to create the source tree')
@@ -1319,7 +1320,8 @@ def register_commands(subparsers, context):
1319 parser_add.set_defaults(func=add) 1320 parser_add.set_defaults(func=add)
1320 1321
1321 parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe', 1322 parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe',
1322 description='Enables modifying the source for an existing recipe. You can either provide your own pre-prepared source tree, or specify -x/--extract to extract the source being fetched by the recipe.') 1323 description='Enables modifying the source for an existing recipe. You can either provide your own pre-prepared source tree, or specify -x/--extract to extract the source being fetched by the recipe.',
1324 group='starting', order=90)
1323 parser_modify.add_argument('recipename', help='Name of existing recipe to edit (just name - no version, path or extension)') 1325 parser_modify.add_argument('recipename', help='Name of existing recipe to edit (just name - no version, path or extension)')
1324 parser_modify.add_argument('srctree', nargs='?', help='Path to external source tree. If not specified, a subdirectory of %s will be used.' % defsrctree) 1326 parser_modify.add_argument('srctree', nargs='?', help='Path to external source tree. If not specified, a subdirectory of %s will be used.' % defsrctree)
1325 parser_modify.add_argument('--wildcard', '-w', action="store_true", help='Use wildcard for unversioned bbappend') 1327 parser_modify.add_argument('--wildcard', '-w', action="store_true", help='Use wildcard for unversioned bbappend')
@@ -1333,7 +1335,8 @@ def register_commands(subparsers, context):
1333 parser_modify.set_defaults(func=modify) 1335 parser_modify.set_defaults(func=modify)
1334 1336
1335 parser_extract = subparsers.add_parser('extract', help='Extract the source for an existing recipe', 1337 parser_extract = subparsers.add_parser('extract', help='Extract the source for an existing recipe',
1336 description='Extracts the source for an existing recipe') 1338 description='Extracts the source for an existing recipe',
1339 group='advanced')
1337 parser_extract.add_argument('recipename', help='Name of recipe to extract the source for') 1340 parser_extract.add_argument('recipename', help='Name of recipe to extract the source for')
1338 parser_extract.add_argument('srctree', help='Path to where to extract the source tree') 1341 parser_extract.add_argument('srctree', help='Path to where to extract the source tree')
1339 parser_extract.add_argument('--branch', '-b', default="devtool", help='Name for development branch to checkout (default "%(default)s")') 1342 parser_extract.add_argument('--branch', '-b', default="devtool", help='Name for development branch to checkout (default "%(default)s")')
@@ -1342,7 +1345,8 @@ def register_commands(subparsers, context):
1342 1345
1343 parser_sync = subparsers.add_parser('sync', help='Synchronize the source tree for an existing recipe', 1346 parser_sync = subparsers.add_parser('sync', help='Synchronize the source tree for an existing recipe',
1344 description='Synchronize the previously extracted source tree for an existing recipe', 1347 description='Synchronize the previously extracted source tree for an existing recipe',
1345 formatter_class=argparse.ArgumentDefaultsHelpFormatter) 1348 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
1349 group='advanced')
1346 parser_sync.add_argument('recipename', help='Name of recipe to sync the source for') 1350 parser_sync.add_argument('recipename', help='Name of recipe to sync the source for')
1347 parser_sync.add_argument('srctree', help='Path to the source tree') 1351 parser_sync.add_argument('srctree', help='Path to the source tree')
1348 parser_sync.add_argument('--branch', '-b', default="devtool", help='Name for development branch to checkout') 1352 parser_sync.add_argument('--branch', '-b', default="devtool", help='Name for development branch to checkout')
@@ -1350,7 +1354,8 @@ def register_commands(subparsers, context):
1350 parser_sync.set_defaults(func=sync) 1354 parser_sync.set_defaults(func=sync)
1351 1355
1352 parser_update_recipe = subparsers.add_parser('update-recipe', help='Apply changes from external source tree to recipe', 1356 parser_update_recipe = subparsers.add_parser('update-recipe', help='Apply changes from external source tree to recipe',
1353 description='Applies changes from external source tree to a recipe (updating/adding/removing patches as necessary, or by updating SRCREV). Note that these changes need to have been committed to the git repository in order to be recognised.') 1357 description='Applies changes from external source tree to a recipe (updating/adding/removing patches as necessary, or by updating SRCREV). Note that these changes need to have been committed to the git repository in order to be recognised.',
1358 group='working', order=-90)
1354 parser_update_recipe.add_argument('recipename', help='Name of recipe to update') 1359 parser_update_recipe.add_argument('recipename', help='Name of recipe to update')
1355 parser_update_recipe.add_argument('--mode', '-m', choices=['patch', 'srcrev', 'auto'], default='auto', help='Update mode (where %(metavar)s is %(choices)s; default is %(default)s)', metavar='MODE') 1360 parser_update_recipe.add_argument('--mode', '-m', choices=['patch', 'srcrev', 'auto'], default='auto', help='Update mode (where %(metavar)s is %(choices)s; default is %(default)s)', metavar='MODE')
1356 parser_update_recipe.add_argument('--initial-rev', help='Override starting revision for patches') 1361 parser_update_recipe.add_argument('--initial-rev', help='Override starting revision for patches')
@@ -1360,11 +1365,13 @@ def register_commands(subparsers, context):
1360 parser_update_recipe.set_defaults(func=update_recipe) 1365 parser_update_recipe.set_defaults(func=update_recipe)
1361 1366
1362 parser_status = subparsers.add_parser('status', help='Show workspace status', 1367 parser_status = subparsers.add_parser('status', help='Show workspace status',
1363 description='Lists recipes currently in your workspace and the paths to their respective external source trees') 1368 description='Lists recipes currently in your workspace and the paths to their respective external source trees',
1369 group='info', order=100)
1364 parser_status.set_defaults(func=status) 1370 parser_status.set_defaults(func=status)
1365 1371
1366 parser_reset = subparsers.add_parser('reset', help='Remove a recipe from your workspace', 1372 parser_reset = subparsers.add_parser('reset', help='Remove a recipe from your workspace',
1367 description='Removes the specified recipe from your workspace (resetting its state)') 1373 description='Removes the specified recipe from your workspace (resetting its state)',
1374 group='working', order=-100)
1368 parser_reset.add_argument('recipename', nargs='?', help='Recipe to reset') 1375 parser_reset.add_argument('recipename', nargs='?', help='Recipe to reset')
1369 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)') 1376 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)')
1370 parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output') 1377 parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output')