From 779796f57e1e0236ea502248ede2cbea986fca21 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 23 Sep 2014 11:47:40 -0700 Subject: futility: Improve help messages 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 Reviewed-on: https://chromium-review.googlesource.com/219528 Reviewed-by: Randall Spangler --- futility/cmd_vbutil_keyblock.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'futility/cmd_vbutil_keyblock.c') 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> [OPTIONS]\n" + "Usage: " MYNAME " %s <--pack|--unpack> [OPTIONS]\n" "\n" "For '--pack ', required OPTIONS are:\n" " --datapubkey 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 " - " 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); -- cgit v1.2.1