summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-20 23:20:48 +0800
committerGitHub <noreply@github.com>2023-03-20 23:20:48 +0800
commit601a5134d047bda03415432aa3250802e2e15554 (patch)
treed32795aabdc360ff37fa4b9ec1a1657df49f337f
parent19ce62ab769b74a8e417cd1213b7711a5ed55638 (diff)
downloadaichat-601a5134d047bda03415432aa3250802e2e15554.tar.gz
feat: add `--dry-run` (#83)
-rw-r--r--src/cli.rs3
-rw-r--r--src/config/mod.rs3
-rw-r--r--src/main.rs3
3 files changed, 6 insertions, 3 deletions
diff --git a/src/cli.rs b/src/cli.rs
index fd56e8b..5531283 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -27,6 +27,9 @@ pub struct Cli {
/// Print information
#[clap(long)]
pub info: bool,
+ /// Run in dry run mode
+ #[clap(long)]
+ pub dry_run: bool,
/// Input text
text: Vec<String>,
}
diff --git a/src/config/mod.rs b/src/config/mod.rs
index e3d81cb..8b6a6ac 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -480,9 +480,6 @@ impl Config {
}
fn merge_env_vars(&mut self) {
- if let Ok(value) = env::var(get_env_name("dry_run")) {
- set_bool(&mut self.dry_run, &value);
- }
if let Ok(value) = env::var(get_env_name("light_theme")) {
set_bool(&mut self.light_theme, &value);
}
diff --git a/src/main.rs b/src/main.rs
index f8d2eeb..af772ca 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -41,6 +41,9 @@ fn main() -> Result<()> {
.for_each(|(name, _)| println!("{}", name));
exit(0);
}
+ if cli.dry_run {
+ config.write().dry_run = true;
+ }
let role = match &cli.role {
Some(name) => Some(
config