forked from EvoLogics/sdmsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell_help.c
38 lines (31 loc) · 1.03 KB
/
shell_help.c
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
#include <stdio.h>
#include <string.h> /* strcmp() */
#include <shell.h>
#include <shell_help.h>
void shell_help_show_drivers(struct shell_config *sc, char *shift)
{
struct driver_t *drv;
printf("%s<driver> is:\n", shift);
for (drv = sc->drivers; drv->name != NULL; drv++)
printf("\t%s%s.\n\t%s%s\n\n", shift, drv->usage, shift, drv->help);
}
void shell_help_show(struct shell_config *sc, char *name)
{
struct commands_t *cmd;
for (cmd = sc->commands; cmd->name != NULL; cmd++) {
if (!name || !strcmp(cmd->name, name)) {
printf ("%-10s-\t%s\n", cmd->name, cmd->help);
printf ("%-10s \tUsage: %s\n", " ", cmd->usage ? cmd->usage : cmd->name);
if (name) {
if (cmd->flags & SCF_USE_DRIVER)
shell_help_show_drivers(sc, "\t\t");
break;
}
}
}
if (!name)
shell_help_show_drivers(sc, "");
if (name && cmd->name == NULL) {
fprintf(stderr, "Unknown topic: %s\n", name);
}
}