From a31b02791bd2baf4171c78d13c710ba05f50485b Mon Sep 17 00:00:00 2001 From: taichong Date: Wed, 3 Jul 2024 23:26:01 +0800 Subject: [PATCH] fix clippy --- cli/src/config.rs | 5 +---- cli/src/main.rs | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/cli/src/config.rs b/cli/src/config.rs index 5562cd7b..312659ec 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -223,10 +223,7 @@ impl Config { fn load_from_file(path: &str) -> Self { match toml::from_str(&std::fs::read_to_string(path).unwrap()) { - Ok(config) => { - println!("path is {:?}", path); - config - } + Ok(config) => config, Err(e) => { eprintln!("failed to load config file {}: {}, using defaults", path, e); Self::default() diff --git a/cli/src/main.rs b/cli/src/main.rs index 7caece52..14535e3e 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -258,13 +258,15 @@ pub async fn main() -> Result<()> { if tls { eprintln!("warning: --tls is ignored when --dsn is set"); } - } else { - if let Some(tls) = config.connection.args.get("tls") { - if tls.to_lowercase() == "true" { - eprintln!("warning: --tls is ignored when --dsn is set") - } + } else if let Some(tls) = config.connection.args.get("tls") { + if tls.to_lowercase() == "true" { + eprintln!("warning: --tls is ignored when --dsn is set") } + } else if config.connection.args.get("tls").is_none() { + // args.tls is none and not config in config.toml + eprintln!("warning: --tls is ignored when --dsn is set"); } + if args.flight { eprintln!("warning: --flight is ignored when --dsn is set"); } @@ -306,14 +308,17 @@ pub async fn main() -> Result<()> { .args .insert("sslmode".to_string(), "disable".to_string()); } - } else { - if let Some(tls) = conn_args.args.get("tls") { - if tls.to_lowercase() != "true" { - conn_args - .args - .insert("sslmode".to_string(), "disable".to_string()); - } + } else if let Some(tls) = conn_args.args.get("tls") { + if tls.to_lowercase() == "false" { + conn_args + .args + .insert("sslmode".to_string(), "disable".to_string()); } + } else if conn_args.args.get("tls").is_none() { + // means arg.tls is none and not config in config.toml + conn_args + .args + .insert("sslmode".to_string(), "disable".to_string()); } // override args if specified in command line @@ -329,7 +334,6 @@ pub async fn main() -> Result<()> { } let dsn = conn_args.get_dsn()?; - println!("not set dsn : {}", dsn.clone()); let mut settings = Settings::default(); let is_terminal = stdin().is_terminal(); let is_repl = is_terminal && !args.non_interactive && !args.check && args.query.is_none();