summaryrefslogtreecommitdiffstats
path: root/src/repl/mod.rs
diff options
context:
space:
mode:
authorLeo Bergnéhr <leo@bergnehr.se>2023-10-26 13:25:53 +0200
committerGitHub <noreply@github.com>2023-10-26 19:25:53 +0800
commitc3f9ef6c396ba692e82cdfaa929429c85eebd289 (patch)
treec2fb59abefe4618f3f0cbf0094f82d8e8c91e97c /src/repl/mod.rs
parent66fd547c0fac30d98565a92d93824237a4813669 (diff)
downloadaichat-c3f9ef6c396ba692e82cdfaa929429c85eebd289.tar.gz
feat: add .read command (#145)
Diffstat (limited to 'src/repl/mod.rs')
-rw-r--r--src/repl/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 311ca72..7c99757 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -17,7 +17,7 @@ use anyhow::{Context, Result};
use reedline::Signal;
use std::rc::Rc;
-pub const REPL_COMMANDS: [(&str, &str); 13] = [
+pub const REPL_COMMANDS: [(&str, &str); 14] = [
(".info", "Print system-wide information"),
(".set", "Modify the configuration temporarily"),
(".model", "Choose a model"),
@@ -31,6 +31,7 @@ pub const REPL_COMMANDS: [(&str, &str); 13] = [
(".clear history", "Clear the history"),
(".help", "Print this help message"),
(".exit", "Exit the REPL"),
+ (".read", "Read the contents of a file into the prompt"),
];
impl Repl {
@@ -118,6 +119,10 @@ impl Repl {
Some(name) => handler.handle(ReplCmd::SetRole(name.to_string()))?,
None => print_now!("Usage: .role <name>\n\n"),
},
+ ".read" => match args {
+ Some(file) => handler.handle(ReplCmd::ReadFile(file.to_string()))?,
+ None => print_now!("Usage: .read <file name>\n\n"),
+ },
".info" => {
handler.handle(ReplCmd::ViewInfo)?;
}