diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli.rs | 3 | ||||
| -rw-r--r-- | src/config/mod.rs | 2 | ||||
| -rw-r--r-- | src/main.rs | 3 | ||||
| -rw-r--r-- | src/repl/handler.rs | 2 |
4 files changed, 8 insertions, 2 deletions
@@ -3,6 +3,9 @@ use clap::Parser; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] pub struct Cli { + /// Add a GPT prompt + #[clap(short, long)] + pub prompt: Option<String>, /// Turn off highlight #[clap(short = 'H', long)] pub no_highlight: bool, diff --git a/src/config/mod.rs b/src/config/mod.rs index 147d944..b438687 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -193,7 +193,7 @@ impl Config { Ok(()) } - pub fn create_temp_role(&mut self, prompt: &str) -> Result<()> { + pub fn add_prompt(&mut self, prompt: &str) -> Result<()> { let role = Role::new(prompt, self.temperature); if let Some(conversation) = self.conversation.as_mut() { conversation.update_role(&role)?; diff --git a/src/main.rs b/src/main.rs index b198d14..5bcdf11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,6 +48,9 @@ fn main() -> Result<()> { if cli.no_highlight { config.lock().highlight = false; } + if let Some(prompt) = &cli.prompt { + config.lock().add_prompt(prompt)?; + } let no_stream = cli.no_stream; let client = ChatGptClient::init(config.clone())?; if atty::isnt(atty::Stream::Stdin) { diff --git a/src/repl/handler.rs b/src/repl/handler.rs index 2263ca2..ce95855 100644 --- a/src/repl/handler.rs +++ b/src/repl/handler.rs @@ -75,7 +75,7 @@ impl ReplCmdHandler { print_now!("\n"); } ReplCmd::Prompt(prompt) => { - self.config.lock().create_temp_role(&prompt)?; + self.config.lock().add_prompt(&prompt)?; print_now!("\n"); } ReplCmd::ViewInfo => { |
