diff options
author | Chee Yang Lee <chee.yang.lee@intel.com> | 2019-11-08 11:41:19 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-11-14 13:20:59 +0000 |
commit | 621b10f0075bc5d499a2151661c6e1a414f12953 (patch) | |
tree | 48e42f143e81d824112a77e42ae99d9b016b8ed4 | |
parent | 70573f66ecf7b591f2d1329dcd4267c9d71ca6ce (diff) | |
download | poky-621b10f0075bc5d499a2151661c6e1a414f12953.tar.gz |
wic: beautify 'wic help'
The Wic help returned to the user is unreadable.
Use a custom ArgumentParser to override argparse help message.
change help message as suggest in
https://bugzilla.yoctoproject.org/show_bug.cgi?id=12205
[YOCTO #12205]
changes applies to 'wic help', 'wic -h', 'wic --h' and 'wic --help'
(From OE-Core rev: d29d553cc096f4e1208c44dc595e1cf365c3dff3)
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/wic/help.py | 56 | ||||
-rwxr-xr-x | scripts/wic | 8 |
2 files changed, 61 insertions, 3 deletions
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py index af7d0576e2..968cc0ed6f 100644 --- a/scripts/lib/wic/help.py +++ b/scripts/lib/wic/help.py | |||
@@ -1046,3 +1046,59 @@ NAME | |||
1046 | DESCRIPTION | 1046 | DESCRIPTION |
1047 | Specify a help topic to display it. Topics are shown above. | 1047 | Specify a help topic to display it. Topics are shown above. |
1048 | """ | 1048 | """ |
1049 | |||
1050 | |||
1051 | wic_help = """ | ||
1052 | Creates a customized OpenEmbedded image. | ||
1053 | |||
1054 | Usage: wic [--version] | ||
1055 | wic help [COMMAND or TOPIC] | ||
1056 | wic COMMAND [ARGS] | ||
1057 | |||
1058 | usage 1: Returns the current version of Wic | ||
1059 | usage 2: Returns detailed help for a COMMAND or TOPIC | ||
1060 | usage 3: Executes COMMAND | ||
1061 | |||
1062 | |||
1063 | COMMAND: | ||
1064 | |||
1065 | list - List available canned images and source plugins | ||
1066 | ls - List contents of partitioned image or partition | ||
1067 | rm - Remove files or directories from the vfat or ext* partitions | ||
1068 | help - Show help for a wic COMMAND or TOPIC | ||
1069 | write - Write an image to a device | ||
1070 | cp - Copy files and directories to the vfat or ext* partitions | ||
1071 | create - Create a new OpenEmbedded image | ||
1072 | |||
1073 | |||
1074 | TOPIC: | ||
1075 | overview - Presents an overall overview of Wic | ||
1076 | plugins - Presents an overview and API for Wic plugins | ||
1077 | kickstart - Presents a Wic kicstart file reference | ||
1078 | |||
1079 | |||
1080 | Examples: | ||
1081 | |||
1082 | $ wic --version | ||
1083 | |||
1084 | Returns the current version of Wic | ||
1085 | |||
1086 | |||
1087 | $ wic help cp | ||
1088 | |||
1089 | Returns the SYNOPSIS and DESCRIPTION for the Wic "cp" command. | ||
1090 | |||
1091 | |||
1092 | $ wic list images | ||
1093 | |||
1094 | Returns the list of canned images (i.e. *.wks files located in | ||
1095 | the /scripts/lib/wic/canned-wks directory. | ||
1096 | |||
1097 | |||
1098 | $ wic create mkefidisk -e core-image-minimal | ||
1099 | |||
1100 | Creates an EFI disk image from artifacts used in a previous | ||
1101 | core-image-minimal build in standard BitBake locations | ||
1102 | (e.g. Cooked Mode). | ||
1103 | |||
1104 | """ | ||
diff --git a/scripts/wic b/scripts/wic index 1d89fb2eda..1a717300f5 100755 --- a/scripts/wic +++ b/scripts/wic | |||
@@ -495,14 +495,18 @@ def init_parser(parser): | |||
495 | subparser = subparsers.add_parser(subcmd, help=subcommands[subcmd][2]) | 495 | subparser = subparsers.add_parser(subcmd, help=subcommands[subcmd][2]) |
496 | subcommands[subcmd][3](subparser) | 496 | subcommands[subcmd][3](subparser) |
497 | 497 | ||
498 | class WicArgumentParser(argparse.ArgumentParser): | ||
499 | def format_help(self): | ||
500 | return hlp.wic_help | ||
498 | 501 | ||
499 | def main(argv): | 502 | def main(argv): |
500 | parser = argparse.ArgumentParser( | 503 | parser = WicArgumentParser( |
501 | description="wic version %s" % __version__) | 504 | description="wic version %s" % __version__) |
502 | 505 | ||
503 | init_parser(parser) | 506 | init_parser(parser) |
504 | 507 | ||
505 | args = parser.parse_args(argv) | 508 | args = parser.parse_args(argv) |
509 | |||
506 | if args.debug: | 510 | if args.debug: |
507 | logger.setLevel(logging.DEBUG) | 511 | logger.setLevel(logging.DEBUG) |
508 | 512 | ||
@@ -510,8 +514,6 @@ def main(argv): | |||
510 | if args.command == "help": | 514 | if args.command == "help": |
511 | if args.help_topic is None: | 515 | if args.help_topic is None: |
512 | parser.print_help() | 516 | parser.print_help() |
513 | print() | ||
514 | print("Please specify a help topic") | ||
515 | elif args.help_topic in helptopics: | 517 | elif args.help_topic in helptopics: |
516 | hlpt = helptopics[args.help_topic] | 518 | hlpt = helptopics[args.help_topic] |
517 | hlpt[0](hlpt[1], hlpt[2]) | 519 | hlpt[0](hlpt[1], hlpt[2]) |