aboutsummaryrefslogtreecommitdiffstats
path: root/src/hci/commands/sanboot_cmd.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2013-11-07 17:00:51 +0000
committerMichael Brown <mcb30@ipxe.org>2013-11-07 17:00:51 +0000
commit43eba2f555e2a2ed0fbedeeda73dd1720437fd97 (patch)
tree86e2decd0adbcb0e92ed8aed80b0b38023e7605a /src/hci/commands/sanboot_cmd.c
parent6871a8113f784f5fedb67f245e15699cdfb2b8f7 (diff)
downloadipxe-43eba2f555e2a2ed0fbedeeda73dd1720437fd97.tar.gz
[cmdline] Generate command option help text automatically
Generate the command option help text automatically from the list of defined options. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci/commands/sanboot_cmd.c')
-rw-r--r--src/hci/commands/sanboot_cmd.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/hci/commands/sanboot_cmd.c b/src/hci/commands/sanboot_cmd.c
index 14055a8c4..5954b6326 100644
--- a/src/hci/commands/sanboot_cmd.c
+++ b/src/hci/commands/sanboot_cmd.c
@@ -46,30 +46,38 @@ struct sanboot_options {
};
/** "sanboot" option list */
-static struct option_descriptor sanboot_opts[] = {
- OPTION_DESC ( "drive", 'd', required_argument,
- struct sanboot_options, drive, parse_integer ),
- OPTION_DESC ( "no-describe", 'n', no_argument,
- struct sanboot_options, no_describe, parse_flag ),
- OPTION_DESC ( "keep", 'k', no_argument,
- struct sanboot_options, keep, parse_flag ),
+static union {
+ /* "sanboot" takes all three options */
+ struct option_descriptor sanboot[3];
+ /* "sanhook" takes only --drive and --no-describe */
+ struct option_descriptor sanhook[2];
+ /* "sanunhook" takes only --drive */
+ struct option_descriptor sanunhook[1];
+} opts = {
+ .sanboot = {
+ OPTION_DESC ( "drive", 'd', required_argument,
+ struct sanboot_options, drive, parse_integer ),
+ OPTION_DESC ( "no-describe", 'n', no_argument,
+ struct sanboot_options, no_describe, parse_flag ),
+ OPTION_DESC ( "keep", 'k', no_argument,
+ struct sanboot_options, keep, parse_flag ),
+ },
};
+
/** "sanhook" command descriptor */
static struct command_descriptor sanhook_cmd =
- COMMAND_DESC ( struct sanboot_options, sanboot_opts, 1, 1,
- "[--drive <drive>] [--no-describe] <root-path>" );
+ COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, 1,
+ "<root-path>" );
/** "sanboot" command descriptor */
static struct command_descriptor sanboot_cmd =
- COMMAND_DESC ( struct sanboot_options, sanboot_opts, 0, 1,
- "[--drive <drive>] [--no-describe] [--keep] "
+ COMMAND_DESC ( struct sanboot_options, opts.sanboot, 0, 1,
"[<root-path>]" );
/** "sanunhook" command descriptor */
static struct command_descriptor sanunhook_cmd =
- COMMAND_DESC ( struct sanboot_options, sanboot_opts, 0, 0,
- "[--drive <drive>]" );
+ COMMAND_DESC ( struct sanboot_options, opts.sanunhook, 0, 0, NULL );
/**
* The "sanboot", "sanhook" and "sanunhook" commands