diff options
Diffstat (limited to 'Source/Applications/Shell')
-rw-r--r-- | Source/Applications/Shell/Help.txt | 2 | ||||
-rw-r--r-- | Source/Applications/Shell/Makefile | 6 | ||||
-rw-r--r-- | Source/Applications/Shell/Shell-fs.ns.cpp | 35 | ||||
-rw-r--r-- | Source/Applications/Shell/Shell.ns.cpp | 10 | ||||
-rw-r--r-- | Source/Applications/Shell/Shell.ns.h | 2 | ||||
-rw-r--r-- | Source/Applications/Shell/main.cpp | 2 |
6 files changed, 52 insertions, 5 deletions
diff --git a/Source/Applications/Shell/Help.txt b/Source/Applications/Shell/Help.txt index c1209cf..0b42361 100644 --- a/Source/Applications/Shell/Help.txt +++ b/Source/Applications/Shell/Help.txt @@ -4,7 +4,7 @@ - help shows this - reboot reboots your computer root - halt shuts down your computer root - - loadkeys loads a new keymap root + - loadkeys loads a keymap root - free shows free amount of RAM - uptime shows computer's uptime - run runs a binary file diff --git a/Source/Applications/Shell/Makefile b/Source/Applications/Shell/Makefile index 0eeb620..bf81af6 100644 --- a/Source/Applications/Shell/Makefile +++ b/Source/Applications/Shell/Makefile @@ -1,10 +1,10 @@ .PHONY: clean, mrproper CXX = g++ -CXXFLAGS = -nostartfiles -nostdlib -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND +CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND LD = ld -LDFLAGS = -T ../../Library/Link.ld +LDFLAGS = -T ../../Library/Link.ld -L ../../Library Objects = main.o \ Shell.ns.o \ @@ -18,7 +18,7 @@ rebuild: mrproper all $(OutFile): $(Objects) echo "* Linking $@..." - $(LD) $(LDFLAGS) ../../Library/Melon.o $^ -o $@ + $(LD) $(LDFLAGS) $^ -o $@ %.o: %.cpp echo "* Compiling $<..." diff --git a/Source/Applications/Shell/Shell-fs.ns.cpp b/Source/Applications/Shell/Shell-fs.ns.cpp index b7e585a..1d52836 100644 --- a/Source/Applications/Shell/Shell-fs.ns.cpp +++ b/Source/Applications/Shell/Shell-fs.ns.cpp @@ -1,4 +1,5 @@ #include "Shell.ns.h" +#include <TextFile.class.h> namespace Shell { @@ -77,4 +78,38 @@ void mkdir(Vector<String>& args) { } } +void cat(Vector<String>& args) { + if (args.size() == 1) outvt << "Meow.\n"; + for (u32int i = 1; i < args.size(); i++) { + TextFile f(args[i], FM_READ, cwd); + if (f.valid() && f.validOpened()) { + while (!f.eof()) { + outvt << f.readLine() << "\n"; + } + f.close(); + } else { + outvt << "Error while reading from file " << args[i] << "\n"; + } + } +} + +void wf(Vector<String>& args) { + if (args.size() == 1) { + outvt << "No file to write !\n"; + } else { + TextFile f(args[1], FM_TRUNCATE, cwd); + if (f.valid() && f.validOpened()) { + outvt << "Enter contents for file " << args[1] << " and end your entry with <CR>.<CR>\n"; + String t = invt.readLine(); + while (t != ".") { + f.write(t, true); + t = invt.readLine(); + } + f.close(); + } else { + outvt << "Error opening file.\n"; + } + } +} + } diff --git a/Source/Applications/Shell/Shell.ns.cpp b/Source/Applications/Shell/Shell.ns.cpp index fe8c5f9..7213094 100644 --- a/Source/Applications/Shell/Shell.ns.cpp +++ b/Source/Applications/Shell/Shell.ns.cpp @@ -16,6 +16,8 @@ u32int run() { {"pwd", pwd}, {"rm", rm}, {"mkdir", mkdir}, + {"cat", cat}, + {"wf", wf}, {"", 0} }; @@ -56,6 +58,14 @@ u32int run() { } else if (cmd[0] == "reboot") { Sys::reboot(); outvt << "Something went wrong.\n"; + } else if (cmd[0] == "uptime") { + outvt << "Uptime : " << (s64int)Sys::uptime() << "s\n"; + } else if (cmd[0] == "free") { + outvt << "Free RAM : " << (s64int)Sys::freeRam() << " Kio of " << (s64int)Sys::totalRam() << " Kio\n"; + } else if (cmd[0] == "help") { + while (cmd.size() > 1) cmd.pop(); + cmd.push("/Applications/Shell/Help.txt"); + cat(cmd); } else { u32int i = 0; bool found = false; diff --git a/Source/Applications/Shell/Shell.ns.h b/Source/Applications/Shell/Shell.ns.h index 56fdb46..a22c18d 100644 --- a/Source/Applications/Shell/Shell.ns.h +++ b/Source/Applications/Shell/Shell.ns.h @@ -12,4 +12,6 @@ namespace Shell { extern void pwd(Vector<String>& args); extern void rm(Vector<String>& args); extern void mkdir(Vector<String>& args); + extern void cat(Vector<String>& args); + extern void wf(Vector<String>& args); } diff --git a/Source/Applications/Shell/main.cpp b/Source/Applications/Shell/main.cpp index 70da17b..66c4269 100644 --- a/Source/Applications/Shell/main.cpp +++ b/Source/Applications/Shell/main.cpp @@ -1,5 +1,5 @@ #include "Shell.ns.h" -int main() { +int main(const Vector<String>& args) { return Shell::run(); } |