diff options
author | Bill Richardson <wfrichar@chromium.org> | 2014-09-23 11:47:40 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-24 00:59:02 +0000 |
commit | 779796f57e1e0236ea502248ede2cbea986fca21 (patch) | |
tree | ccb33230dec19efa3d9e93888b875e70276f1db6 /futility/cmd_vbutil_keyblock.c | |
parent | 0f07867e6fe186ea460afd557e830c1e49f1ff85 (diff) | |
download | vboot-779796f57e1e0236ea502248ede2cbea986fca21.tar.gz |
futility: Improve help messagesstabilize-6297.B
This provides help messages for the futility commands similar to
the way git does. These show the available commands:
futility
futility help
futility --help
While these show help for a specific command:
futility help COMMAND
futility --help COMMAND
futility COMMAND --help
BUG=none
BRANCH=ToT
TEST=manual
make runtests
And manually look at help messages for each command.
Change-Id: I1126471e242784c6ca7a2f11694fa7c505d833e8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219528
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'futility/cmd_vbutil_keyblock.c')
-rw-r--r-- | futility/cmd_vbutil_keyblock.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/futility/cmd_vbutil_keyblock.c b/futility/cmd_vbutil_keyblock.c index 58d89c1a..c73fd9ae 100644 --- a/futility/cmd_vbutil_keyblock.c +++ b/futility/cmd_vbutil_keyblock.c @@ -44,9 +44,8 @@ static const struct option long_opts[] = { }; static const char usage[] = - "Verified boot key block utility\n" "\n" - "Usage: %s <--pack|--unpack> <file> [OPTIONS]\n" + "Usage: " MYNAME " %s <--pack|--unpack> <file> [OPTIONS]\n" "\n" "For '--pack <file>', required OPTIONS are:\n" " --datapubkey <file> Data public key in .vbpubk format\n" @@ -70,13 +69,11 @@ static const char usage[] = " Signing public key in .vbpubk format. This is required to\n" " verify a signed keyblock.\n" " --datapubkey <file>" - " Write the data public key to this file.\n"; + " Write the data public key to this file.\n\n"; -/* Print help and return error */ -static int PrintHelp(char *progname) +static void print_help(const char *progname) { - fprintf(stderr, usage, progname); - return 1; + printf(usage, progname); } /* Pack a .keyblock */ @@ -240,12 +237,6 @@ static int do_vbutil_keyblock(int argc, char *argv[]) char *e; int i; - char *progname = strrchr(argv[0], '/'); - if (progname) - progname++; - else - progname = argv[0]; - while ((i = getopt_long(argc, argv, "", long_opts, NULL)) != -1) { switch (i) { case '?': @@ -321,8 +312,10 @@ static int do_vbutil_keyblock(int argc, char *argv[]) parse_error = 1; } - if (parse_error) - return PrintHelp(progname); + if (parse_error) { + print_help(argv[0]); + return 1; + } switch (mode) { case OPT_MODE_PACK: @@ -333,9 +326,11 @@ static int do_vbutil_keyblock(int argc, char *argv[]) return Unpack(filename, datapubkey, signpubkey); default: printf("Must specify a mode.\n"); - return PrintHelp(progname); + print_help(argv[0]); + return 1; } } DECLARE_FUTIL_COMMAND(vbutil_keyblock, do_vbutil_keyblock, - "Verified boot key block utility"); + "Creates, signs, and verifies a keyblock", + print_help); |