diff options
author | marvinborner | 2019-09-18 11:02:15 +0200 |
---|---|---|
committer | marvinborner | 2019-09-18 11:02:15 +0200 |
commit | 8e0c4dc52871e720f793db0b21e1b4f504cefcf9 (patch) | |
tree | de337614c048f378343c287028945602a7fb7347 /src/commands | |
parent | a6b67d12dc98e48fae69c8df411a3dda65ea48cf (diff) |
Added basic command support
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/command.c | 17 | ||||
-rw-r--r-- | src/commands/command.h | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/commands/command.c b/src/commands/command.c new file mode 100644 index 0000000..ee53c90 --- /dev/null +++ b/src/commands/command.c @@ -0,0 +1,17 @@ +#include "../graphics/graphics.h" +#include "../lib/lib.h" + +int32_t starts_with(const char *a, const char *b) { + if (strcmp(a, b, strlen(b)) == 0) + return 1 + return 0 +} + +void exec_command(char *command) { + if (starts_with(command, "ls")) + terminal_write_string("// listing files"); + else if (starts_with(command, "help")) + terminal_write_string("I can't help you write now"); + else if (starts_with(command, "ping")) + terminal_write_string("pong!") +} diff --git a/src/commands/command.h b/src/commands/command.h new file mode 100644 index 0000000..2a43416 --- /dev/null +++ b/src/commands/command.h @@ -0,0 +1,6 @@ +#ifndef MELVIX_COMMAND_H +#define MELVIX_COMMAND_H + +void exec_command(char *command); + +#endif |