diff --git a/ramdisk/shell.c b/ramdisk/shell.c index b1cd05c..15d8a73 100644 --- a/ramdisk/shell.c +++ b/ramdisk/shell.c @@ -1,4 +1,6 @@ #include "nox/stdio.h" +#include "nox/memory.h" +#include "nox/math.h" #define COMMAND_BUFFER_SIZE 512 @@ -26,14 +28,36 @@ int read_command(char* command_buffer) { return pos; } +bool handle_command(char* command_buffer) { + int command_length = strlen(command_buffer); + + if (command_length < 2) return true; + + if (memcmp(command_buffer, "help", min(4, command_length))) { + printf("Commands:\n"); + printf(" help | shows this help message\n"); + printf(" exit | exit noxsh\n"); + } else if (memcmp(command_buffer, "exit", min(4, command_length))) { + printf("exiting noxsh\n"); + return false; + } else { + printf("Unknown command: '"); + printf(command_buffer); + printf("'\n"); + } + + return true; +} + void _start() { printf("Welcome to the nox shell.\ntype 'help' for a list of commands\n"); bool running = true; while(running) { - printf("\n>>> "); + printf("\n[/]=> "); char command_buffer[COMMAND_BUFFER_SIZE]; read_command(command_buffer); + running = handle_command(command_buffer); } } \ No newline at end of file diff --git a/ramdisk/shell.elf b/ramdisk/shell.elf index 5599c10..0830d75 100755 Binary files a/ramdisk/shell.elf and b/ramdisk/shell.elf differ