aboutsummaryrefslogtreecommitdiff
path: root/frontend/cli.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-28 15:41:35 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-28 15:41:35 +0100
commit3562802cacc8dbd0c155146acfdb8d04c6440009 (patch)
treef2139c64c6713d1c59df4b8601c11fca52fa62f5 /frontend/cli.cpp
parenta070c649ddbe70a22f6265b9f5b48f6bde7eac08 (diff)
implement transcript-style log
Diffstat (limited to 'frontend/cli.cpp')
-rw-r--r--frontend/cli.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/frontend/cli.cpp b/frontend/cli.cpp
index 352de4a..de78bc1 100644
--- a/frontend/cli.cpp
+++ b/frontend/cli.cpp
@@ -5,31 +5,34 @@
#include <readline/history.h>
#include "cli.h"
+#include "frontend/print.h"
+#include "strings.h"
+#include "cmd.h"
using namespace std;
-static void handle_line(const string & line) {
- printf("CMD: %s\n", line.c_str());
-}
-
string cli_readline() {
const char * PROMPT = "> ";
char * input = readline(PROMPT);
- // ctrl-d
- if (input == NULL) exit(EXIT_SUCCESS);
+ SessionLog::get().append(PROMPT);
+ if (input == NULL) exit(EXIT_SUCCESS); // ctrl-d
string out = string(input);
if (out.size() > 0) add_history(input);
free(input);
+ SessionLog::get().append(out);
+ SessionLog::get().append("\n");
+
return out;
}
void cli_main() {
while (1) {
- string cmd = cli_readline();
- if (cmd.size() == 0) continue;
- handle_line(cmd);
+ string line = cli_readline();
+ if (line.length() == 0) continue;
+ vector<string> argv = split_string(line, " ");
+ cmd_handle(argv);
}
}