diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-17 10:59:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-17 10:59:59 +0800 |
| commit | 189f2271bcc6f841264cb960e35e78c870663645 (patch) | |
| tree | 88dfcce749695668582c05bdc024b1a39ffc06e5 /src/repl | |
| parent | 72e689fab0b414ea943c300c3eb92901c77ce775 (diff) | |
| download | aichat-189f2271bcc6f841264cb960e35e78c870663645.tar.gz | |
feat: add `.edit session` repl command (#606)
Diffstat (limited to 'src/repl')
| -rw-r--r-- | src/repl/mod.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 48d8224..5b37d36 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -33,7 +33,7 @@ lazy_static! { const MENU_NAME: &str = "completion_menu"; lazy_static! { - static ref REPL_COMMANDS: [ReplCommand; 23] = [ + static ref REPL_COMMANDS: [ReplCommand; 24] = [ ReplCommand::new(".help", "Show this help message", AssertState::pass()), ReplCommand::new(".info", "View system info", AssertState::pass()), ReplCommand::new(".model", "Change the current LLM", AssertState::pass()), @@ -73,6 +73,11 @@ lazy_static! { AssertState::True(StateFlags::SESSION_EMPTY | StateFlags::SESSION) ), ReplCommand::new( + ".edit session", + "Edit the current session", + AssertState::True(StateFlags::SESSION_EMPTY | StateFlags::SESSION) + ), + ReplCommand::new( ".clear messages", "Erase messages in the current session", AssertState::True(StateFlags::SESSION) @@ -279,8 +284,8 @@ Tips: use <tab> to autocomplete conversation starter text. }, ".save" => { match args.map(|v| match v.split_once(' ') { - Some((subcmd, args)) => (subcmd, args.trim()), - None => (v, ""), + Some((subcmd, args)) => (subcmd, Some(args.trim())), + None => (v, None), }) { Some(("session", name)) => { self.config.write().save_session(name)?; @@ -290,6 +295,19 @@ Tips: use <tab> to autocomplete conversation starter text. } } } + ".edit" => { + match args.map(|v| match v.split_once(' ') { + Some((subcmd, args)) => (subcmd, Some(args.trim())), + None => (v, None), + }) { + Some(("session", _)) => { + self.config.write().edit_session()?; + } + _ => { + println!(r#"Usage: .edit session"#) + } + } + } ".set" => match args { Some(args) => { self.config.write().update(args)?; |
