mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
* shell: added help,
* shell: fixed default shell commands
This commit is contained in:
parent
2e94065cd9
commit
07681a1914
@ -36,6 +36,7 @@ and the mailinglist (subscription via web site)
|
||||
|
||||
typedef struct shell_command_t {
|
||||
char* name;
|
||||
char* desc;
|
||||
void (*handler)(char*);
|
||||
} shell_command_t;
|
||||
|
||||
|
@ -61,6 +61,17 @@ static void(*find_handler(const shell_command_t *command_list, char *command))(c
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void print_help(const shell_command_t *command_list) {
|
||||
const shell_command_t *entry = command_list;
|
||||
|
||||
printf("%-20s %s\n", "Command", "Description");
|
||||
|
||||
while(entry->name != NULL) {
|
||||
printf("%-20s %s\n", entry->name, entry->desc);
|
||||
entry++;
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_input_line(shell_t *shell, char* line) {
|
||||
char* saveptr;
|
||||
char* linedup = strdup(line);
|
||||
@ -73,7 +84,11 @@ static void handle_input_line(shell_t *shell, char* line) {
|
||||
if (handler != NULL) {
|
||||
handler(line);
|
||||
} else {
|
||||
puts("shell: command not found.");
|
||||
if ( strcmp("help", command) == 0) {
|
||||
print_help(shell->command_list);
|
||||
} else {
|
||||
puts("shell: command not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
#include <shell.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef MODULE_PS
|
||||
extern void _ps_handler(char* unnused);
|
||||
#endif
|
||||
|
||||
const shell_command_t _shell_command_list[] = {
|
||||
#ifdef MODULE_PS
|
||||
{"ps", ps_handler},
|
||||
{"ps", "Prints information about running threads.", _ps_handler},
|
||||
#endif
|
||||
{NULL, NULL}
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user