diff options
| author | Marty Connor | 2006-08-09 04:30:35 +0200 |
|---|---|---|
| committer | Marty Connor | 2006-08-09 04:30:35 +0200 |
| commit | 41af7457a8c731ed358f70ae3c78983893ae84ad (patch) | |
| tree | 1049f7efa4a666efb7905e135ce4b0e90393a2fb /src/commandline/commands | |
| parent | Add a couple of small but vital parts to PXENV_UDP_WRITE. (diff) | |
| download | ipxe-41af7457a8c731ed358f70ae3c78983893ae84ad.tar.gz ipxe-41af7457a8c731ed358f70ae3c78983893ae84ad.tar.xz ipxe-41af7457a8c731ed358f70ae3c78983893ae84ad.zip | |
Merge of Fredrik Hultin command_line
Diffstat (limited to 'src/commandline/commands')
| -rw-r--r-- | src/commandline/commands/help.c | 48 | ||||
| -rw-r--r-- | src/commandline/commands/test.c | 22 | ||||
| -rw-r--r-- | src/commandline/commands/test2.c | 22 |
3 files changed, 92 insertions, 0 deletions
diff --git a/src/commandline/commands/help.c b/src/commandline/commands/help.c new file mode 100644 index 000000000..30ab96231 --- /dev/null +++ b/src/commandline/commands/help.c @@ -0,0 +1,48 @@ +#include "command.h" +#include "console.h" +#include <string.h> +#include <gpxe/tables.h> + +static struct command cmd_start[0] __table_start ( commands ); +static struct command cmd_end[0] __table_end ( commands ); + +void help_req(){} + +static int cmd_help_exec ( int argc, char **argv ) { + + struct command *ccmd; + int unknown = 1; + if(argc == 1){ + printf("Built in commands:\n\n\texit, quit\t\tExit the command line and boot\n\nCompiled in commands:\n\n"); + + for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) { + printf ("\t%s\t\t%s\n", ccmd->name, ccmd->desc ); + } + }else{ + if(!strcmp(argv[1], "exit") || !strcmp(argv[1], "quit")){ + printf("exit, quit - The quit command\n\nUsage:\nquit or exit\n\n\tExample:\n\t\texit\n"); + }else{ + for ( ccmd = cmd_start ; ccmd < cmd_end ; ccmd++ ) { + if(!strcmp(ccmd->name, argv[1])){ + unknown = 0; + printf ("\t%s - %s\n\nUsage:\n%s\n", ccmd->name, ccmd->desc, ccmd->usage ); + break; + } + } + if(unknown){ + printf("\"%s\" isn't compiled in (does it exist?).\n", argv[1]); + } + } + + } + return 0; +} + +struct command help_command __command = { + .name = "help", + .usage = "help <command>\n\n\tExample:\n\t\thelp help\n", + .desc = "The help command", + .exec = cmd_help_exec, +}; + + diff --git a/src/commandline/commands/test.c b/src/commandline/commands/test.c new file mode 100644 index 000000000..1d3701247 --- /dev/null +++ b/src/commandline/commands/test.c @@ -0,0 +1,22 @@ +#include "command.h" +#include "console.h" + +void test_req(){} + +static int cmd_test_exec ( int argc, char **argv ) { + int i; + + printf("Hello, world!\nI got the following arguments passed to me: \n"); + for(i = 0; i < argc; i++){ + printf("%d: \"%s\"\n", i, argv[i]); + } + return 0; +} + +struct command test_command __command = { + .name = "test", + .usage = "A test command\nIt does nothing at all\n\nExample:\n\ttest", + .desc = "Does nothing", + .exec = cmd_test_exec, +}; + diff --git a/src/commandline/commands/test2.c b/src/commandline/commands/test2.c new file mode 100644 index 000000000..077933d0e --- /dev/null +++ b/src/commandline/commands/test2.c @@ -0,0 +1,22 @@ +#include "command.h" +#include "console.h" + +void test2_req(){} + +static int cmd_test2_exec ( int argc, char **argv ) { + int i; + + printf("Hello, world!\nI got the following arguments passed to me: \n"); + for(i = 0; i < argc; i++){ + printf("%d: \"%s\"\n", i, argv[i]); + } + return 0; +} + +struct command test2_command __command = { + .name = "test2", + .usage = "A test command\nIt does nothing at all\n\nExample:\n\ttest2", + .desc = "Does nothing", + .exec = cmd_test2_exec, +}; + |
