summaryrefslogtreecommitdiffstats
path: root/src/repl/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2025-01-18 08:46:33 +0800
committerGitHub <noreply@github.com>2025-01-18 08:46:33 +0800
commit58c3cdc9d9c65ff2ef89eaf16588e613d9ca2f49 (patch)
tree402afb39fa89f0fc21448aec2aeb17d41aa4244f /src/repl/mod.rs
parentd37d99c63dafaa606ece5aa3b36ad9c5e58e5cbb (diff)
downloadaichat-58c3cdc9d9c65ff2ef89eaf16588e613d9ca2f49.tar.gz
feat: `.starter` accepts index other than text (#1093)
Diffstat (limited to 'src/repl/mod.rs')
-rw-r--r--src/repl/mod.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 1d96885..ef7921d 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -13,7 +13,7 @@ use crate::config::{
};
use crate::render::render_error;
use crate::utils::{
- abortable_run_with_spinner, create_abort_signal, set_text, temp_file, AbortSignal,
+ abortable_run_with_spinner, create_abort_signal, dimmed_text, set_text, temp_file, AbortSignal,
};
use anyhow::{bail, Context, Result};
@@ -450,9 +450,25 @@ pub async fn run_repl_command(
}
},
".starter" => match args {
- Some(value) => {
- let input = Input::from_str(config, value, None);
- ask(config, abort_signal.clone(), input, true).await?;
+ Some(id) => {
+ let mut text = None;
+ if let Some(agent) = config.read().agent.as_ref() {
+ for (i, value) in agent.conversation_staters().iter().enumerate() {
+ if (i + 1).to_string() == id {
+ text = Some(value.clone());
+ }
+ }
+ }
+ match text {
+ Some(text) => {
+ println!("{}", dimmed_text(&format!(">> {}", text)));
+ let input = Input::from_str(config, &text, None);
+ ask(config, abort_signal.clone(), input, true).await?;
+ }
+ None => {
+ bail!("Invalid starter value");
+ }
+ }
}
None => {
let banner = config.read().agent_banner()?;