summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/help.py
diff options
context:
space:
mode:
authorAndreas J. Reichel <andreas.reichel@tngtech.com>2017-04-21 14:11:42 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-05-21 12:32:01 +0100
commit4fe9635c72a6ee1becc47d832ab54724176ee811 (patch)
tree87677da0ff9ca16f7014bac51ed032cd5dd8d64f /scripts/lib/wic/help.py
parentee55b5685aaa4be92d6d51f8641a559d4e34ce64 (diff)
downloadopenembedded-core-contrib-4fe9635c72a6ee1becc47d832ab54724176ee811.tar.gz
wic: Use argparse instead of optparse
* optparse is deprecated and will not be developed further (see: https://docs.python.org/2/library/optparse.html) * argparse supports subcommands, which simplifies definition of arguments and options * reimplement help mechanism through sub-subcommands [YOCTO #9636] Signed-off-by: Andreas Reichel <andreas.reichel.ext@siemens.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib/wic/help.py')
-rw-r--r--scripts/lib/wic/help.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index d6e027d253..74db05cb94 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -56,7 +56,7 @@ def wic_help(args, usage_str, subcommands):
"""
Subcommand help dispatcher.
"""
- if len(args) == 1 or not display_help(args[1], subcommands):
+ if args.help_topic == None or not display_help(args.help_topic, subcommands):
print(usage_str)
@@ -82,19 +82,20 @@ def invoke_subcommand(args, parser, main_command_usage, subcommands):
Dispatch to subcommand handler borrowed from combo-layer.
Should use argparse, but has to work in 2.6.
"""
- if not args:
+ if not args.command:
logger.error("No subcommand specified, exiting")
parser.print_help()
return 1
- elif args[0] == "help":
+ elif args.command == "help":
wic_help(args, main_command_usage, subcommands)
- elif args[0] not in subcommands:
- logger.error("Unsupported subcommand %s, exiting\n", args[0])
+ elif args.command not in subcommands:
+ logger.error("Unsupported subcommand %s, exiting\n", args.command)
parser.print_help()
return 1
else:
- usage = subcommands.get(args[0], subcommand_error)[1]
- subcommands.get(args[0], subcommand_error)[0](args[1:], usage)
+ subcmd = subcommands.get(args.command, subcommand_error)
+ usage = subcmd[1]
+ subcmd[0](args, usage)
##
@@ -795,3 +796,11 @@ DESCRIPTION
.wks files.
"""
+
+wic_help_help = """
+NAME
+ wic help - display a help topic
+
+DESCRIPTION
+ Specify a help topic to display it. Topics are shown above.
+"""