summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/utilcmds.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/utilcmds.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/utilcmds.py')
-rw-r--r--scripts/lib/devtool/utilcmds.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/lib/devtool/utilcmds.py b/scripts/lib/devtool/utilcmds.py
index 18eddb78b0..905d6d2b19 100644
--- a/scripts/lib/devtool/utilcmds.py
+++ b/scripts/lib/devtool/utilcmds.py
@@ -214,7 +214,8 @@ The ./configure %s output for %s follows.
214def register_commands(subparsers, context): 214def register_commands(subparsers, context):
215 """Register devtool subcommands from this plugin""" 215 """Register devtool subcommands from this plugin"""
216 parser_edit_recipe = subparsers.add_parser('edit-recipe', help='Edit a recipe file in your workspace', 216 parser_edit_recipe = subparsers.add_parser('edit-recipe', help='Edit a recipe file in your workspace',
217 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.') 217 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.',
218 group='working')
218 parser_edit_recipe.add_argument('recipename', help='Recipe to edit') 219 parser_edit_recipe.add_argument('recipename', help='Recipe to edit')
219 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') 220 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')
220 parser_edit_recipe.set_defaults(func=edit_recipe) 221 parser_edit_recipe.set_defaults(func=edit_recipe)
@@ -223,7 +224,8 @@ def register_commands(subparsers, context):
223 # gets the order wrong - recipename must come before --arg 224 # gets the order wrong - recipename must come before --arg
224 parser_configure_help = subparsers.add_parser('configure-help', help='Get help on configure script options', 225 parser_configure_help = subparsers.add_parser('configure-help', help='Get help on configure script options',
225 usage='devtool configure-help [options] recipename [--arg ...]', 226 usage='devtool configure-help [options] recipename [--arg ...]',
226 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.') 227 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.',
228 group='working')
227 parser_configure_help.add_argument('recipename', help='Recipe to show configure help for') 229 parser_configure_help.add_argument('recipename', help='Recipe to show configure help for')
228 parser_configure_help.add_argument('-p', '--no-pager', help='Disable paged output', action="store_true") 230 parser_configure_help.add_argument('-p', '--no-pager', help='Disable paged output', action="store_true")
229 parser_configure_help.add_argument('-n', '--no-header', help='Disable explanatory header text', action="store_true") 231 parser_configure_help.add_argument('-n', '--no-header', help='Disable explanatory header text', action="store_true")