From 02475a16ebbe0550d513bd75f51887c92c932870 Mon Sep 17 00:00:00 2001 From: Tao Lu Date: Tue, 25 Apr 2023 09:50:49 -0500 Subject: [PATCH 1/2] cargo fmt --- rozy/src/config.rs | 4 +++- rozy/src/main.rs | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/rozy/src/config.rs b/rozy/src/config.rs index 8150768..a68c166 100644 --- a/rozy/src/config.rs +++ b/rozy/src/config.rs @@ -5,7 +5,9 @@ use std::{collections::HashMap, time::SystemTime}; use serde_yaml::Mapping as Config; pub fn config_mtime() -> Result { - return Ok(std::fs::metadata(&get_ozy_dir()?.join("ozy.yaml"))?.modified().unwrap()); + return Ok(std::fs::metadata(&get_ozy_dir()?.join("ozy.yaml"))? + .modified() + .unwrap()); } pub fn load_config(base_config_filename_override: Option<&str>) -> Result { diff --git a/rozy/src/main.rs b/rozy/src/main.rs index cbd6bcb..6af1d15 100644 --- a/rozy/src/main.rs +++ b/rozy/src/main.rs @@ -161,9 +161,11 @@ fn should_update(config: &serde_yaml::Mapping) -> Result { match config.get("ozy_update_every") { Some(serde_yaml::Value::Number(update_every)) => { let update_every = Duration::from_secs(update_every.as_u64().unwrap_or_default()); - let since_last_update = std::time::SystemTime::now().duration_since(config::config_mtime().context("While determining config mtime")?)?; + let since_last_update = std::time::SystemTime::now().duration_since( + config::config_mtime().context("While determining config mtime")?, + )?; return Ok(!update_every.is_zero() && since_last_update >= update_every); - }, + } _ => return Ok(false), } } @@ -471,10 +473,7 @@ fn main() -> Result<(), Error> { makefile_var, app_names, } => makefile_config(makefile_var, app_names, did_path_contain_ozy), - Commands::Run { - app_name, - app_args, - } => run(app_name, app_args), + Commands::Run { app_name, app_args } => run(app_name, app_args), Commands::Update { url } => update(&exe_path, url), Commands::Sync => sync(&exe_path), } From fd742696db9f483eaaedcc185d28848ee11a34aa Mon Sep 17 00:00:00 2001 From: Tao Lu Date: Tue, 18 Jul 2023 11:25:02 -0500 Subject: [PATCH 2/2] Also run clippy --- rozy/src/app.rs | 2 +- rozy/src/config.rs | 4 ++-- rozy/src/main.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rozy/src/app.rs b/rozy/src/app.rs index 6d118c2..d34013b 100644 --- a/rozy/src/app.rs +++ b/rozy/src/app.rs @@ -31,7 +31,7 @@ pub struct App { } pub fn find_app(config: &serde_yaml::Mapping, app: &String) -> Result { - App::new(app, &config) + App::new(app, config) .with_context(|| format!("While attempting to find the app {} to run", app)) } diff --git a/rozy/src/config.rs b/rozy/src/config.rs index a68c166..43def98 100644 --- a/rozy/src/config.rs +++ b/rozy/src/config.rs @@ -5,9 +5,9 @@ use std::{collections::HashMap, time::SystemTime}; use serde_yaml::Mapping as Config; pub fn config_mtime() -> Result { - return Ok(std::fs::metadata(&get_ozy_dir()?.join("ozy.yaml"))? + Ok(std::fs::metadata(&get_ozy_dir()?.join("ozy.yaml"))? .modified() - .unwrap()); + .unwrap()) } pub fn load_config(base_config_filename_override: Option<&str>) -> Result { diff --git a/rozy/src/main.rs b/rozy/src/main.rs index 6af1d15..858e3e6 100644 --- a/rozy/src/main.rs +++ b/rozy/src/main.rs @@ -164,9 +164,9 @@ fn should_update(config: &serde_yaml::Mapping) -> Result { let since_last_update = std::time::SystemTime::now().duration_since( config::config_mtime().context("While determining config mtime")?, )?; - return Ok(!update_every.is_zero() && since_last_update >= update_every); + Ok(!update_every.is_zero() && since_last_update >= update_every) } - _ => return Ok(false), + _ => Ok(false), } }