cargo clippy

This commit is contained in:
2025-03-23 09:06:21 +01:00
parent 63df22f4d8
commit de0cebb3b5

View File

@ -4,7 +4,6 @@ use std::{
fs::{self, File}, fs::{self, File},
io::{self, BufRead, BufReader, Write}, io::{self, BufRead, BufReader, Write},
}; };
use urlencoding;
fn show_usage() { fn show_usage() {
println!("Available options:"); println!("Available options:");
@ -51,7 +50,7 @@ fn run_as_cli() -> i32 {
} }
} }
return result; result
} }
fn run_with_input(arguments: Vec<String>) -> i32 { fn run_with_input(arguments: Vec<String>) -> i32 {
@ -80,7 +79,7 @@ fn run_with_input(arguments: Vec<String>) -> i32 {
} }
} }
return result; result
} }
fn generate_file(client: &mut postgres::Client, website: Option<String>) -> i32 { fn generate_file(client: &mut postgres::Client, website: Option<String>) -> i32 {
@ -99,8 +98,8 @@ fn generate_file(client: &mut postgres::Client, website: Option<String>) -> i32
.query_one("SELECT website_exists($1);", &[&website_name]) .query_one("SELECT website_exists($1);", &[&website_name])
.unwrap(); .unwrap();
let result: bool = output.get(0); let found: bool = output.get(0);
if result == false { if !found {
eprintln!("Invalid website_name"); eprintln!("Invalid website_name");
return 1; return 1;
} }
@ -126,7 +125,7 @@ fn generate_file(client: &mut postgres::Client, website: Option<String>) -> i32
writeln!(file, "{} # {}", url, folder_path).unwrap(); writeln!(file, "{} # {}", url, folder_path).unwrap();
} }
return 0; 0
} }
fn convert_folders(client: &mut postgres::Client, path: Option<String>) -> i32 { fn convert_folders(client: &mut postgres::Client, path: Option<String>) -> i32 {
@ -174,7 +173,7 @@ fn convert_folders(client: &mut postgres::Client, path: Option<String>) -> i32 {
writeln!(log_file, "Converted {} => {}", old_path, new_path).unwrap(); writeln!(log_file, "Converted {} => {}", old_path, new_path).unwrap();
} }
return 0; 0
} }
fn import_file(client: &mut postgres::Client, file: Option<String>) -> i32 { fn import_file(client: &mut postgres::Client, file: Option<String>) -> i32 {
@ -224,7 +223,7 @@ fn import_file(client: &mut postgres::Client, file: Option<String>) -> i32 {
}; };
} }
return 0; 0
} }
fn add_url(client: &mut postgres::Client, uri: Option<String>) -> i32 { fn add_url(client: &mut postgres::Client, uri: Option<String>) -> i32 {
@ -253,7 +252,7 @@ fn add_url(client: &mut postgres::Client, uri: Option<String>) -> i32 {
println!("{}", something); println!("{}", something);
return 0; 0
} }
fn add_artist_with_custom_name( fn add_artist_with_custom_name(
@ -297,22 +296,20 @@ fn add_artist_with_custom_name(
println!("{}", something); println!("{}", something);
return 0; 0
} }
fn main() -> Result<(), i32> { fn main() -> Result<(), i32> {
let args: Vec<String> = args().collect(); let args: Vec<String> = args().collect();
let result: i32; let result = if args.len() == 1 {
run_as_cli()
if args.len() == 1 {
result = run_as_cli();
} else { } else {
result = run_with_input(args); run_with_input(args)
} };
if result != 0 { if result != 0 {
return Err(result); return Err(result);
} }
return Ok(()); Ok(())
} }