summaryrefslogtreecommitdiffstats
path: root/src/commandline/commands/help.c
blob: 30ab9623137ac77ffaba6f1b30e4ceb418243e65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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,
};