/** "stoppxe" command descriptor */
static struct command_descriptor stoppxe_cmd =
- COMMAND_DESC ( struct stoppxe_options, stoppxe_opts, 0, 0, "" );
+ COMMAND_DESC ( struct stoppxe_options, stoppxe_opts, 0, 0, NULL );
/**
* The "stoppxe" command
/** "cpuid" command descriptor */
static struct command_descriptor cpuid_cmd =
- COMMAND_DESC ( struct cpuid_options, cpuid_opts, 1, 1,
- "[--ext] [--ecx] <bit>" );
+ COMMAND_DESC ( struct cpuid_options, cpuid_opts, 1, 1, "<bit>" );
/**
* The "cpuid" command
/** "echo" command descriptor */
static struct command_descriptor echo_cmd =
COMMAND_DESC ( struct echo_options, echo_opts, 0, MAX_ARGUMENTS,
- "[-n] [...]" );
+ "[...]" );
/**
* "echo" command
* @v argv Argument list
*/
void print_usage ( struct command_descriptor *cmd, char **argv ) {
- printf ( "Usage:\n\n %s %s\n\nSee http://ipxe.org/cmd/%s for further "
- "information\n", argv[0], cmd->usage, argv[0] );
+ struct option_descriptor *option;
+ unsigned int i;
+ int is_optional;
+
+ printf ( "Usage:\n\n %s", argv[0] );
+ for ( i = 0 ; i < cmd->num_options ; i++ ) {
+ option = &cmd->options[i];
+ printf ( " [-%c|--%s", option->shortopt, option->longopt );
+ if ( option->has_arg ) {
+ is_optional = ( option->has_arg == optional_argument );
+ printf ( " %s<%s>%s", ( is_optional ? "[" : "" ),
+ option->longopt, ( is_optional ? "]" : "" ) );
+ }
+ printf ( "]" );
+ }
+ if ( cmd->usage )
+ printf ( " %s", cmd->usage );
+ printf ( "\n\nSee http://ipxe.org/cmd/%s for further information\n",
+ argv[0] );
}
/**
/** "fcstat" command descriptor */
static struct command_descriptor fcstat_cmd =
- COMMAND_DESC ( struct fcstat_options, fcstat_opts, 0, 0, "" );
+ COMMAND_DESC ( struct fcstat_options, fcstat_opts, 0, 0, NULL );
/**
* The "fcstat" command
/** "fcels" command descriptor */
static struct command_descriptor fcels_cmd =
- COMMAND_DESC ( struct fcels_options, fcels_opts, 1, 1,
- "[--port <port>] [--id <peer port id>] <request>" );
+ COMMAND_DESC ( struct fcels_options, fcels_opts, 1, 1, "<request>" );
/**
* The "fcels" command
/** "ifconf" command descriptor */
static struct ifcommon_command_descriptor ifconf_cmd =
IFCOMMON_COMMAND_DESC ( struct ifconf_options, ifconf_opts,
- 0, MAX_ARGUMENTS,
- "[--configurator <configurator>] "
- "[<interface>...]",
+ 0, MAX_ARGUMENTS, "[<interface>...]",
ifconf_payload, 1 );
/**
};
/** "img{single}" option list */
-static struct option_descriptor imgsingle_opts[] = {
- OPTION_DESC ( "name", 'n', required_argument,
- struct imgsingle_options, name, parse_string ),
- OPTION_DESC ( "replace", 'r', no_argument,
- struct imgsingle_options, replace, parse_flag ),
- OPTION_DESC ( "autofree", 'a', no_argument,
- struct imgsingle_options, autofree, parse_flag ),
+static union {
+ /* "imgexec" takes all three options */
+ struct option_descriptor imgexec[3];
+ /* Other "img{single}" commands take only --name and --autofree */
+ struct option_descriptor imgsingle[2];
+} opts = {
+ .imgexec = {
+ OPTION_DESC ( "name", 'n', required_argument,
+ struct imgsingle_options, name, parse_string ),
+ OPTION_DESC ( "autofree", 'a', no_argument,
+ struct imgsingle_options, autofree, parse_flag ),
+ OPTION_DESC ( "replace", 'r', no_argument,
+ struct imgsingle_options, replace, parse_flag ),
+ },
};
-/** "img{single}" command descriptor */
-static struct command_descriptor imgsingle_cmd =
- COMMAND_DESC ( struct imgsingle_options, imgsingle_opts,
- 1, MAX_ARGUMENTS,
- "[--name <name>] [--autofree] "
- "<uri|image> [<arguments>...]" );
-
/** An "img{single}" family command descriptor */
struct imgsingle_descriptor {
/** Command descriptor */
/** "imgfetch" command descriptor */
static struct command_descriptor imgfetch_cmd =
- COMMAND_DESC ( struct imgsingle_options, imgsingle_opts,
- 1, MAX_ARGUMENTS,
- "[--name <name>] [--autofree] <uri> [<arguments>...]" );
+ COMMAND_DESC ( struct imgsingle_options, opts.imgsingle,
+ 1, MAX_ARGUMENTS, "<uri> [<arguments>...]" );
/** "imgfetch" family command descriptor */
struct imgsingle_descriptor imgfetch_desc = {
return image_select ( image );
}
+/** "imgselect" command descriptor */
+static struct command_descriptor imgselect_cmd =
+ COMMAND_DESC ( struct imgsingle_options, opts.imgsingle,
+ 1, MAX_ARGUMENTS, "<uri|image> [<arguments>...]" );
+
/** "imgselect" family command descriptor */
struct imgsingle_descriptor imgselect_desc = {
- .cmd = &imgsingle_cmd,
+ .cmd = &imgselect_cmd,
.acquire = imgacquire,
.action = imgselect,
.verb = "select",
/** "imgexec" command descriptor */
static struct command_descriptor imgexec_cmd =
- COMMAND_DESC ( struct imgsingle_options, imgsingle_opts,
- 0, MAX_ARGUMENTS,
- "[--autofree] [--replace] "
- "[<uri|image> [<arguments>...]]" );
+ COMMAND_DESC ( struct imgsingle_options, opts.imgexec,
+ 0, MAX_ARGUMENTS, "[<uri|image> [<arguments>...]]" );
/**
* "imgexec" command action
return imgsingle_exec ( argc, argv, &imgexec_desc );
}
+/** "imgargs" command descriptor */
+static struct command_descriptor imgargs_cmd =
+ COMMAND_DESC ( struct imgsingle_options, opts.imgsingle,
+ 1, MAX_ARGUMENTS, "<uri|image> [<arguments>...]" );
+
/** "imgargs" family command descriptor */
struct imgsingle_descriptor imgargs_desc = {
- .cmd = &imgsingle_cmd,
+ .cmd = &imgargs_cmd,
.acquire = imgacquire,
.preaction = image_clear_cmdline,
};
/** "imgtrust" command descriptor */
static struct command_descriptor imgtrust_cmd =
- COMMAND_DESC ( struct imgtrust_options, imgtrust_opts, 0, 0,
- "[--allow] [--permanent]" );
+ COMMAND_DESC ( struct imgtrust_options, imgtrust_opts, 0, 0, NULL );
/**
* The "imgtrust" command
/** "imgverify" command descriptor */
static struct command_descriptor imgverify_cmd =
COMMAND_DESC ( struct imgverify_options, imgverify_opts, 2, 2,
- "[--signer <signer>] [--keep] <uri|image> "
- "<signature uri|image>" );
+ "<uri|image> <signature uri|image>" );
/**
* The "imgverify" command
/** "login" command descriptor */
static struct command_descriptor login_cmd =
- COMMAND_DESC ( struct login_options, login_opts, 0, 0, "" );
+ COMMAND_DESC ( struct login_options, login_opts, 0, 0, NULL );
/**
* "login" command
/** "lotest" command descriptor */
static struct command_descriptor lotest_cmd =
COMMAND_DESC ( struct lotest_options, lotest_opts, 2, 2,
- "[--mtu <mtu>] <sending interface> "
- "<receiving interface>" );
+ "<sending interface> <receiving interface>" );
/**
* "lotest" command
/** "menu" command descriptor */
static struct command_descriptor menu_cmd =
COMMAND_DESC ( struct menu_options, menu_opts, 0, MAX_ARGUMENTS,
- "[--name <name>] [--delete] [<title>]" );
+ "[<title>]" );
/**
* The "menu" command
/** "item" command descriptor */
static struct command_descriptor item_cmd =
COMMAND_DESC ( struct item_options, item_opts, 0, MAX_ARGUMENTS,
- "[--menu <menu>] [--key <key>] [--default] "
- "[<label>|--gap [<text>]]" );
+ "[<label> [<text>]]" );
/**
* The "item" command
/** "choose" command descriptor */
static struct command_descriptor choose_cmd =
- COMMAND_DESC ( struct choose_options, choose_opts, 1, 1,
- "[--menu <menu>] [--default <label>] "
- "[--timeout <timeout>] [--keep] <setting>" );
+ COMMAND_DESC ( struct choose_options, choose_opts, 1, 1, "<setting>" );
/**
* The "choose" command
/** "nstat" command descriptor */
static struct command_descriptor nstat_cmd =
- COMMAND_DESC ( struct nstat_options, nstat_opts, 0, 0, "" );
+ COMMAND_DESC ( struct nstat_options, nstat_opts, 0, 0, NULL );
/**
* The "nstat" command
/** "params" command descriptor */
static struct command_descriptor params_cmd =
- COMMAND_DESC ( struct params_options, params_opts, 0, 0,
- "[--name <name>] [--delete]" );
+ COMMAND_DESC ( struct params_options, params_opts, 0, 0, NULL );
/**
* The "params" command
/** "param" command descriptor */
static struct command_descriptor param_cmd =
COMMAND_DESC ( struct param_options, param_opts, 1, MAX_ARGUMENTS,
- "[--params <params>] <key> [<value>]" );
+ "<key> [<value>]" );
/**
* The "param" command
/** "ping" command descriptor */
static struct command_descriptor ping_cmd =
- COMMAND_DESC ( struct ping_options, ping_opts, 1, 1,
- "[--size <size>] [--timeout <timeout>] <host>" );
+ COMMAND_DESC ( struct ping_options, ping_opts, 1, 1, "<host>" );
/**
* The "ping" command
/** "poweroff" command descriptor */
static struct command_descriptor poweroff_cmd =
- COMMAND_DESC ( struct poweroff_options, poweroff_opts, 0, 0, "" );
+ COMMAND_DESC ( struct poweroff_options, poweroff_opts, 0, 0, NULL );
/**
* The "poweroff" command
/** "reboot" command descriptor */
static struct command_descriptor reboot_cmd =
- COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, "[--warm]" );
+ COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, NULL );
/**
* The "reboot" command
/** "route" command descriptor */
static struct command_descriptor route_cmd =
- COMMAND_DESC ( struct route_options, route_opts, 0, 0, "" );
+ COMMAND_DESC ( struct route_options, route_opts, 0, 0, NULL );
/**
* The "route" command
};
/** "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
/** "sync" command descriptor */
static struct command_descriptor sync_cmd =
- COMMAND_DESC ( struct sync_options, sync_opts, 0, 0,
- "[--timeout <timeout>]" );
+ COMMAND_DESC ( struct sync_options, sync_opts, 0, 0, NULL );
/**
* "sync" command
/** "vcreate" command descriptor */
static struct command_descriptor vcreate_cmd =
COMMAND_DESC ( struct vcreate_options, vcreate_opts, 1, 1,
- "--tag <tag> [--priority <priority>] "
"<trunk interface>" );
/**
/** "shell" command descriptor */
static struct command_descriptor shell_cmd =
- COMMAND_DESC ( struct shell_options, shell_opts, 0, 0, "" );
+ COMMAND_DESC ( struct shell_options, shell_opts, 0, 0, NULL );
/**
* "shell" command
/** "prompt" command descriptor */
static struct command_descriptor prompt_cmd =
COMMAND_DESC ( struct prompt_options, prompt_opts, 0, MAX_ARGUMENTS,
- "[--key <key>] [--timeout <timeout>] [<text>]" );
+ "[<text>]" );
/**
* "prompt" command