From c5cbf51e75170eb5f2e949442100d2437f57a1e2 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 2 May 2023 21:21:07 +0200 Subject: [PATCH] feature (shell): implemented basic interactions --- ramdisk/shell.c | 26 +++++++++++++++++++++++++- ramdisk/shell.elf | Bin 17992 -> 20408 bytes 2 files changed, 25 insertions(+), 1 deletion(-) 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 5599c106495b0db4779b4bb41c19ba5d6dbcb64e..0830d75a275508ed41fb4a7ce5079fea7e9cd6eb 100755 GIT binary patch literal 20408 zcmeHPeQ=b=dEb5S_H_C{IuJ&};BfK>5Qt6!W6XyP2TA z@!shqVUte(NpENFefIg>=XrMb-QD-SyZ!#gbr$E$6bDC6S(DQSwoMgeeD>9)o~x28J)N$*>lpABbgIRlM{1W9kQQbC4M3}haKlb)ce z#N;YFzaFcG&z)U?dSzV>{s#lMN!wO{v8a+zK)##agQcmdes?KLN zyivDjAjwkM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