From f858f2c4a044820f57f1c8967a95ba6031e5f9fb Mon Sep 17 00:00:00 2001 From: Enoki Date: Fri, 19 Jan 2024 22:19:13 +0300 Subject: [PATCH] chore: appease Clippy --- Cargo.lock | 8 +++----- Cargo.toml | 1 + src/user.rs | 10 ++++------ src/version.rs | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4764688..fce9b24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -924,12 +924,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "mac-notification-sys" @@ -1189,6 +1186,7 @@ dependencies = [ "discord-rich-presence", "futures", "lazy_static", + "log", "notify-rust", "rand", "regex", diff --git a/Cargo.toml b/Cargo.toml index a6cbf8b..9ef41d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ directories = "5.0.1" discord-rich-presence = "0.2.3" futures = "0.3.23" lazy_static = "1.4.0" +log = "0.4.20" notify-rust = "4.5.10" rand = "0.8.5" regex = "1.8.4" diff --git a/src/user.rs b/src/user.rs index c1ab747..d3add1a 100644 --- a/src/user.rs +++ b/src/user.rs @@ -27,19 +27,17 @@ pub async fn get_token( http_client: &Client, ) -> Result<(String, String), anyhow::Error> { let conf_dir = match env::var("PILFER_CONF") { - Ok(dir) => Ok::(PathBuf::try_from(dir).context( - "Could not convert the `PILFER_CONF` environment variable into a valid path", - )?), - Err(env::VarError::NotPresent) => Ok(ProjectDirs::from("", "eludris", "pilfer") + Ok(dir) => PathBuf::from(dir), + Err(env::VarError::NotPresent) => ProjectDirs::from("", "eludris", "pilfer") // According to the `directories` docs the error is raised when a home path isn't found // but that wouldn't make much sense for windows so we use `base` here. .context("Could not find a valid base directory")? .config_dir() - .to_path_buf()), + .to_path_buf(), Err(env::VarError::NotUnicode(_)) => { bail!("The value of the `PILFER_CONF` environment variable must be a valid unicode string") } - }?; + }; if !conf_dir.exists() { fs::create_dir_all(&conf_dir) diff --git a/src/version.rs b/src/version.rs index 680c48a..a2535ce 100644 --- a/src/version.rs +++ b/src/version.rs @@ -20,8 +20,8 @@ pub fn check_version(info: &InstanceInfo) -> Result<(), String> { let instance_version = VERSION_REGEX .captures(&info.version) .ok_or("Error: Instance version is not a valid semver.")?; - println!("Current version: {}", env!("CARGO_PKG_VERSION")); - println!("Instance version: {}", info.version); + log::info!("Current version: {}", env!("CARGO_PKG_VERSION")); + log::info!("Instance version: {}", info.version); let current_major = current_version .name("major")