diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/exec.c | 2 | ||||
| -rw-r--r-- | src/core/parseopt.c | 21 |
2 files changed, 20 insertions, 3 deletions
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] ); } /** |
