diff options
-rw-r--r-- | src/arch/i386/hci/commands/pxe_cmd.c | 2 | ||||
-rw-r--r-- | src/arch/x86/hci/commands/cpuid_cmd.c | 3 | ||||
-rw-r--r-- | src/core/exec.c | 2 | ||||
-rw-r--r-- | src/core/parseopt.c | 21 | ||||
-rw-r--r-- | src/hci/commands/fcmgmt_cmd.c | 5 | ||||
-rw-r--r-- | src/hci/commands/ifmgmt_cmd.c | 4 | ||||
-rw-r--r-- | src/hci/commands/image_cmd.c | 53 | ||||
-rw-r--r-- | src/hci/commands/image_trust_cmd.c | 6 | ||||
-rw-r--r-- | src/hci/commands/login_cmd.c | 2 | ||||
-rw-r--r-- | src/hci/commands/lotest_cmd.c | 3 | ||||
-rw-r--r-- | src/hci/commands/menu_cmd.c | 9 | ||||
-rw-r--r-- | src/hci/commands/neighbour_cmd.c | 2 | ||||
-rw-r--r-- | src/hci/commands/param_cmd.c | 5 | ||||
-rw-r--r-- | src/hci/commands/ping_cmd.c | 3 | ||||
-rw-r--r-- | src/hci/commands/poweroff_cmd.c | 2 | ||||
-rw-r--r-- | src/hci/commands/reboot_cmd.c | 2 | ||||
-rw-r--r-- | src/hci/commands/route_cmd.c | 2 | ||||
-rw-r--r-- | src/hci/commands/sanboot_cmd.c | 34 | ||||
-rw-r--r-- | src/hci/commands/sync_cmd.c | 3 | ||||
-rw-r--r-- | src/hci/commands/vlan_cmd.c | 1 | ||||
-rw-r--r-- | src/hci/shell.c | 2 | ||||
-rw-r--r-- | src/image/script.c | 2 |
22 files changed, 93 insertions, 75 deletions
diff --git a/src/arch/i386/hci/commands/pxe_cmd.c b/src/arch/i386/hci/commands/pxe_cmd.c index c7cdb07f8..523724ab0 100644 --- a/src/arch/i386/hci/commands/pxe_cmd.c +++ b/src/arch/i386/hci/commands/pxe_cmd.c @@ -78,7 +78,7 @@ static struct option_descriptor stoppxe_opts[] = {}; /** "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 diff --git a/src/arch/x86/hci/commands/cpuid_cmd.c b/src/arch/x86/hci/commands/cpuid_cmd.c index 981143308..c4e35d179 100644 --- a/src/arch/x86/hci/commands/cpuid_cmd.c +++ b/src/arch/x86/hci/commands/cpuid_cmd.c @@ -54,8 +54,7 @@ static struct option_descriptor cpuid_opts[] = { /** "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 diff --git a/src/core/exec.c b/src/core/exec.c index 843a51db7..1c85705ae 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -397,7 +397,7 @@ static struct option_descriptor echo_opts[] = { /** "echo" command descriptor */ static struct command_descriptor echo_cmd = COMMAND_DESC ( struct echo_options, echo_opts, 0, MAX_ARGUMENTS, - "[-n] [...]" ); + "[...]" ); /** * "echo" command diff --git a/src/core/parseopt.c b/src/core/parseopt.c index 334ffb2cf..d268c0594 100644 --- a/src/core/parseopt.c +++ b/src/core/parseopt.c @@ -326,8 +326,25 @@ int parse_parameters ( char *text, struct parameters **params ) { * @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] ); } /** diff --git a/src/hci/commands/fcmgmt_cmd.c b/src/hci/commands/fcmgmt_cmd.c index 99f76113e..1c199b5dc 100644 --- a/src/hci/commands/fcmgmt_cmd.c +++ b/src/hci/commands/fcmgmt_cmd.c @@ -106,7 +106,7 @@ static struct option_descriptor fcstat_opts[] = {}; /** "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 @@ -151,8 +151,7 @@ static struct option_descriptor fcels_opts[] = { /** "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 diff --git a/src/hci/commands/ifmgmt_cmd.c b/src/hci/commands/ifmgmt_cmd.c index f3d00ca38..5307c9423 100644 --- a/src/hci/commands/ifmgmt_cmd.c +++ b/src/hci/commands/ifmgmt_cmd.c @@ -226,9 +226,7 @@ static int ifconf_payload ( struct net_device *netdev, /** "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 ); /** diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index 17e22dcba..dc30b3f24 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -47,22 +47,22 @@ struct imgsingle_options { }; /** "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 */ @@ -174,9 +174,8 @@ static int imgsingle_exec ( int argc, char **argv, /** "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 = { @@ -207,9 +206,14 @@ static int imgselect ( struct image *image, 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", @@ -228,10 +232,8 @@ static int imgselect_exec ( int argc, char **argv ) { /** "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 @@ -282,9 +284,14 @@ static int imgexec_exec ( int argc, char **argv) { 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, }; diff --git a/src/hci/commands/image_trust_cmd.c b/src/hci/commands/image_trust_cmd.c index ad238bff9..ef4bbfa89 100644 --- a/src/hci/commands/image_trust_cmd.c +++ b/src/hci/commands/image_trust_cmd.c @@ -52,8 +52,7 @@ static struct option_descriptor imgtrust_opts[] = { /** "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 @@ -100,8 +99,7 @@ static struct option_descriptor imgverify_opts[] = { /** "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 diff --git a/src/hci/commands/login_cmd.c b/src/hci/commands/login_cmd.c index bc23e6ff5..f5db427d5 100644 --- a/src/hci/commands/login_cmd.c +++ b/src/hci/commands/login_cmd.c @@ -39,7 +39,7 @@ static struct option_descriptor login_opts[] = {}; /** "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 diff --git a/src/hci/commands/lotest_cmd.c b/src/hci/commands/lotest_cmd.c index 92f08887a..0fa031bcb 100644 --- a/src/hci/commands/lotest_cmd.c +++ b/src/hci/commands/lotest_cmd.c @@ -50,8 +50,7 @@ static struct option_descriptor lotest_opts[] = { /** "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 diff --git a/src/hci/commands/menu_cmd.c b/src/hci/commands/menu_cmd.c index 6ff30083b..66a6262e6 100644 --- a/src/hci/commands/menu_cmd.c +++ b/src/hci/commands/menu_cmd.c @@ -57,7 +57,7 @@ static struct option_descriptor menu_opts[] = { /** "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 @@ -131,8 +131,7 @@ static struct option_descriptor item_opts[] = { /** "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 @@ -215,9 +214,7 @@ static struct option_descriptor choose_opts[] = { /** "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 diff --git a/src/hci/commands/neighbour_cmd.c b/src/hci/commands/neighbour_cmd.c index d65c355c6..a1e052439 100644 --- a/src/hci/commands/neighbour_cmd.c +++ b/src/hci/commands/neighbour_cmd.c @@ -38,7 +38,7 @@ static struct option_descriptor nstat_opts[] = {}; /** "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 diff --git a/src/hci/commands/param_cmd.c b/src/hci/commands/param_cmd.c index 1b466cdae..a30c62af9 100644 --- a/src/hci/commands/param_cmd.c +++ b/src/hci/commands/param_cmd.c @@ -50,8 +50,7 @@ static struct option_descriptor params_opts[] = { /** "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 @@ -96,7 +95,7 @@ static struct option_descriptor param_opts[] = { /** "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 diff --git a/src/hci/commands/ping_cmd.c b/src/hci/commands/ping_cmd.c index 4959f6a00..d514a2a27 100644 --- a/src/hci/commands/ping_cmd.c +++ b/src/hci/commands/ping_cmd.c @@ -60,8 +60,7 @@ static struct option_descriptor ping_opts[] = { /** "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 diff --git a/src/hci/commands/poweroff_cmd.c b/src/hci/commands/poweroff_cmd.c index 159fe6186..9d487d330 100644 --- a/src/hci/commands/poweroff_cmd.c +++ b/src/hci/commands/poweroff_cmd.c @@ -40,7 +40,7 @@ static struct option_descriptor poweroff_opts[] = {}; /** "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 diff --git a/src/hci/commands/reboot_cmd.c b/src/hci/commands/reboot_cmd.c index 44dcfc71c..485939e42 100644 --- a/src/hci/commands/reboot_cmd.c +++ b/src/hci/commands/reboot_cmd.c @@ -44,7 +44,7 @@ static struct option_descriptor reboot_opts[] = { /** "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 diff --git a/src/hci/commands/route_cmd.c b/src/hci/commands/route_cmd.c index 3b51f06b0..cc5ffc2f2 100644 --- a/src/hci/commands/route_cmd.c +++ b/src/hci/commands/route_cmd.c @@ -39,7 +39,7 @@ static struct option_descriptor route_opts[] = {}; /** "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 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 diff --git a/src/hci/commands/sync_cmd.c b/src/hci/commands/sync_cmd.c index 3c9ef2a4d..adf7e3cc6 100644 --- a/src/hci/commands/sync_cmd.c +++ b/src/hci/commands/sync_cmd.c @@ -46,8 +46,7 @@ static struct option_descriptor sync_opts[] = { /** "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 diff --git a/src/hci/commands/vlan_cmd.c b/src/hci/commands/vlan_cmd.c index 822e5dcf3..5d7298220 100644 --- a/src/hci/commands/vlan_cmd.c +++ b/src/hci/commands/vlan_cmd.c @@ -53,7 +53,6 @@ static struct option_descriptor vcreate_opts[] = { /** "vcreate" command descriptor */ static struct command_descriptor vcreate_cmd = COMMAND_DESC ( struct vcreate_options, vcreate_opts, 1, 1, - "--tag <tag> [--priority <priority>] " "<trunk interface>" ); /** diff --git a/src/hci/shell.c b/src/hci/shell.c index b62086769..c1a543849 100644 --- a/src/hci/shell.c +++ b/src/hci/shell.c @@ -107,7 +107,7 @@ static struct option_descriptor shell_opts[] = {}; /** "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 diff --git a/src/image/script.c b/src/image/script.c index 8d80241dc..5328da8b4 100644 --- a/src/image/script.c +++ b/src/image/script.c @@ -375,7 +375,7 @@ static struct option_descriptor prompt_opts[] = { /** "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 |