diff --git a/kernel/commands.c b/kernel/commands.c index 670d23a..d3b45f5 100644 --- a/kernel/commands.c +++ b/kernel/commands.c @@ -3,10 +3,16 @@ void help(struct tokenized_string *tokens) { kprintln("All of the commands:"); + kprintln("`help` - shows this list"); kprintln("`echo` - prints the first argument that is provided"); + kprintln("`clear` - clears the screen"); } void echo(struct tokenized_string *tokens) { kprintln(tokens->indices[1]); +} + +void clear(struct tokenized_string *tokens) { + kclear(); } \ No newline at end of file diff --git a/kernel/commands.h b/kernel/commands.h index bad7b59..55321be 100644 --- a/kernel/commands.h +++ b/kernel/commands.h @@ -5,5 +5,6 @@ void help(struct tokenized_string *tokens); void echo(struct tokenized_string *tokens); +void clear(struct tokenized_string *tokens); #endif \ No newline at end of file diff --git a/kernel/kernel.c b/kernel/kernel.c index df896bc..5e4f37b 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -7,10 +7,11 @@ #include "commands.h" #include "parser.h" +#define FUNC_AMOUNT 3 #define PROMPT "$ " -char **names[2] = {"help", "echo"}; -int (*addresses[2])(struct tokenized_string *) = {&help, &echo}; +char **names[FUNC_AMOUNT] = {"help", "echo", "clear"}; +int (*addresses[FUNC_AMOUNT])(struct tokenized_string *) = {&help, &echo, &clear}; void command_error(char *exception) { kprint("error: "); @@ -21,7 +22,7 @@ void input_callback(char *buffer) { struct tokenized_string *tokens = tokenize_string(buffer); char *name = tokens->indices[0]; // the command name - int index = findsubstr(names, name, 2); + int index = findsubstr(names, name, FUNC_AMOUNT); if (index == -1) { // command name not found command_error("command not found");