mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-14 15:06:52 -04:00
Add help command
This commit is contained in:
parent
4a57f67583
commit
df9475ba49
@ -66,12 +66,44 @@ bool str_equals(const char* a, const char* b){
|
|||||||
return *a == *b;
|
return *a == *b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_command(){
|
#define COMMANDS 2
|
||||||
if(str_equals("reboot", current_input)){
|
|
||||||
interrupt<60>();
|
struct command_definition {
|
||||||
} else {
|
const char* name;
|
||||||
k_print("The command \"");
|
void (*function)();
|
||||||
k_print(current_input);
|
};
|
||||||
k_print_line("\" does not exist");
|
|
||||||
|
void reboot_command();
|
||||||
|
void help_command();
|
||||||
|
|
||||||
|
command_definition commands[COMMANDS] = {
|
||||||
|
{"reboot", reboot_command},
|
||||||
|
{"help", help_command}
|
||||||
|
};
|
||||||
|
|
||||||
|
void reboot_command(){
|
||||||
|
interrupt<60>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void help_command(){
|
||||||
|
k_print_line("Available commands:");
|
||||||
|
|
||||||
|
for(int i = 0; i < COMMANDS; ++i){
|
||||||
|
k_print(" ");
|
||||||
|
k_print_line(commands[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exec_command(){
|
||||||
|
for(int i = 0; i < COMMANDS; ++i){
|
||||||
|
if(str_equals(current_input, commands[i].name)){
|
||||||
|
commands[i].function();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
k_print("The command \"");
|
||||||
|
k_print(current_input);
|
||||||
|
k_print_line("\" does not exist");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user