From 01466d36afd10b3947de475bc9b4fb23848e81ce Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 11 Mar 2015 11:21:47 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/260495 Reviewed-by: Randall Spangler --- futility/cmd_vbutil_kernel.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'futility/cmd_vbutil_kernel.c') diff --git a/futility/cmd_vbutil_kernel.c b/futility/cmd_vbutil_kernel.c index 635acdc4..8ddc5ef2 100644 --- a/futility/cmd_vbutil_kernel.c +++ b/futility/cmd_vbutil_kernel.c @@ -64,6 +64,7 @@ enum { OPT_MINVERSION, OPT_VMLINUZ_OUT, OPT_FLAGS, + OPT_HELP, }; static const struct option long_opts[] = { @@ -87,6 +88,7 @@ static const struct option long_opts[] = { {"verbose", 0, &opt_verbose, 1}, {"vmlinuz-out", 1, 0, OPT_VMLINUZ_OUT}, {"flags", 1, 0, OPT_FLAGS}, + {"help", 0, 0, OPT_HELP}, {NULL, 0, 0, 0} }; @@ -270,6 +272,9 @@ static int do_vbutil_kernel(int argc, char *argv[]) case 0: /* silently handled option */ break; + case OPT_HELP: + print_help(argc, argv); + return !!parse_error; case OPT_MODE_PACK: case OPT_MODE_REPACK: @@ -646,7 +651,5 @@ static int do_vbutil_kernel(int argc, char *argv[]) return 1; } -DECLARE_FUTIL_COMMAND(vbutil_kernel, do_vbutil_kernel, - VBOOT_VERSION_1_0, - "Creates, signs, and verifies the kernel partition", - print_help); +DECLARE_FUTIL_COMMAND(vbutil_kernel, do_vbutil_kernel, VBOOT_VERSION_1_0, + "Creates, signs, and verifies the kernel partition"); -- cgit v1.2.1