Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Jul 3, 2024
1 parent 1c07f41 commit a31b027
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
5 changes: 1 addition & 4 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
30 changes: 17 additions & 13 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit a31b027

Please sign in to comment.