From cfb46ca0de8493a1ab5026cd44f88f092b26f91d Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 6 Mar 2023 09:27:49 +0800 Subject: feat: add `--no-highlight` option (#24) --- src/cli.rs | 5 ++++- src/main.rs | 4 +++- src/repl/mod.rs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index e1adde7..5d709ea 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -6,9 +6,12 @@ pub struct Cli { /// List all roles #[clap(short = 'L', long)] pub list_roles: bool, - /// Specify the role that the AI will play + /// Select a role #[clap(short, long)] pub role: Option, + /// Turn off highlight + #[clap(short = 'H', long)] + pub no_highlight: bool, /// Input text, if no input text, enter interactive mode text: Vec, } diff --git a/src/main.rs b/src/main.rs index 0f12db5..884a56f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,10 +43,12 @@ fn main() -> Result<()> { None => None, }; config.borrow_mut().role = role; + if cli.no_highlight { + config.borrow_mut().highlight = false; + } let client = ChatGptClient::init(config.clone())?; if atty::isnt(atty::Stream::Stdin) { let mut input = String::new(); - config.borrow_mut().highlight = false; stdin().read_to_string(&mut input)?; if let Some(text) = text { input = format!("{text}\n{input}"); diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 30f09fe..826ec6a 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -16,7 +16,7 @@ pub use self::handler::*; pub const REPL_COMMANDS: [(&str, &str, bool); 12] = [ (".info", "Print the information", false), (".set", "Modify the configuration temporarily", false), - (".role", "Specifies the role the AI will play", false), + (".role", "Select a role", false), (".clear role", "Clear the currently selected role", false), (".prompt", "Add prompt, aka create a temporary role", true), (".history", "Print the history", false), -- cgit v1.2.3