summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-10-30 12:58:11 +0800
committerGitHub <noreply@github.com>2023-10-30 12:58:11 +0800
commit2f9121e515150981ac061389656c33eea577c336 (patch)
treed213322b1cff8e1ba94988d6590ead6e4335ff94 /src/main.rs
parentf2c9f00bda1e69306bb2b73843ed7a95cd703bb5 (diff)
downloadaichat-2f9121e515150981ac061389656c33eea577c336.tar.gz
fix: bugs between sesison/role (#178)
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs
index 0d12731..a71a2b5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,7 +11,7 @@ use crate::cli::Cli;
use crate::client::Client;
use crate::config::{Config, SharedConfig};
-use anyhow::{anyhow, Result};
+use anyhow::Result;
use clap::Parser;
use client::{init_client, list_models};
use crossbeam::sync::WaitGroup;
@@ -56,22 +56,15 @@ fn main() -> Result<()> {
if cli.dry_run {
config.write().dry_run = true;
}
- if let Some(session) = &cli.session {
- config.write().start_session(session)?;
- }
if let Some(model) = &cli.model {
config.write().set_model(model)?;
}
- let role = match &cli.role {
- Some(name) => Some(
- config
- .read()
- .get_role(name)
- .ok_or_else(|| anyhow!("Unknown role '{name}'"))?,
- ),
- None => None,
- };
- config.write().role = role;
+ if let Some(name) = &cli.role {
+ config.write().set_role(name)?;
+ }
+ if let Some(session) = &cli.session {
+ config.write().start_session(session)?;
+ }
if cli.no_highlight {
config.write().highlight = false;
}