From 57947fb5ddcd59aeccd262527371a1cd845da029 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Sun, 26 Nov 2023 13:51:35 -0800 Subject: [PATCH] [Teton] Add a command to print the working directory. --- sys/teton/terminal.cpp | 12 +++++++++--- sys/teton/terminal.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/teton/terminal.cpp b/sys/teton/terminal.cpp index c1215a6..a22ee99 100644 --- a/sys/teton/terminal.cpp +++ b/sys/teton/terminal.cpp @@ -14,7 +14,13 @@ void Terminal::HandleCharacter(char c) { } void Terminal::ExecuteCommand(const glcr::String& command) { - console_.WriteString("Executing: "); - console_.WriteString(command); - console_.WriteString("\n>"); + if (command == "cwd") { + console_.WriteString(cwd_); + console_.WriteChar('\n'); + } else { + console_.WriteString("Unknown command: "); + console_.WriteString(command); + console_.WriteChar('\n'); + } + console_.WriteChar('>'); } diff --git a/sys/teton/terminal.h b/sys/teton/terminal.h index 3628141..71408a2 100644 --- a/sys/teton/terminal.h +++ b/sys/teton/terminal.h @@ -14,4 +14,6 @@ class Terminal : public mmth::KeyboardListenerBase { private: Console& console_; glcr::VariableStringBuilder current_command_; + + glcr::String cwd_ = "/"; };