mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-15 20:37:33 +00:00
futility: Let each command provide its own help
Instead of a separate help function for each command, let's just require each command to handle a --help option. This will make it easier to layer the commands (for example, "sign" could have several subcommand variants, each with its own help). BUG=none BRANCH=none TEST=make runtests I also compared the result of running "futility help CMD" before and after this change. The help still shows up correctly. Change-Id: I5c58176f32b41b0a2c2b8f0afb17dddd80fddc70 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/260495 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
49a422fab9
commit
01466d36af
@@ -31,6 +31,7 @@ enum {
|
||||
OPT_DESC,
|
||||
OPT_ID,
|
||||
OPT_HASH_ALG,
|
||||
OPT_HELP,
|
||||
};
|
||||
|
||||
#define DEFAULT_VERSION 1
|
||||
@@ -48,6 +49,7 @@ static const struct option long_opts[] = {
|
||||
{"desc", 1, 0, OPT_DESC},
|
||||
{"id", 1, 0, OPT_ID},
|
||||
{"hash_alg", 1, 0, OPT_HASH_ALG},
|
||||
{"help", 0, 0, OPT_HELP},
|
||||
{NULL, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -331,6 +333,9 @@ static int do_create(int argc, char *argv[])
|
||||
errorcnt++;
|
||||
}
|
||||
break;
|
||||
case OPT_HELP:
|
||||
print_help(argc, argv);
|
||||
return !!errorcnt;
|
||||
|
||||
case '?':
|
||||
if (optopt)
|
||||
@@ -406,7 +411,5 @@ static int do_create(int argc, char *argv[])
|
||||
return r;
|
||||
}
|
||||
|
||||
DECLARE_FUTIL_COMMAND(create, do_create,
|
||||
VBOOT_VERSION_ALL,
|
||||
"Create a keypair from an RSA .pem file",
|
||||
print_help);
|
||||
DECLARE_FUTIL_COMMAND(create, do_create, VBOOT_VERSION_ALL,
|
||||
"Create a keypair from an RSA .pem file");
|
||||
|
||||
Reference in New Issue
Block a user