diff --git a/hipcheck/src/exec.rs b/hipcheck/src/exec.rs index 9275ad36..ba4c2cfa 100644 --- a/hipcheck/src/exec.rs +++ b/hipcheck/src/exec.rs @@ -10,7 +10,7 @@ use crate::{ }, }; use kdl::{KdlDocument, KdlNode, KdlValue}; -use std::{path::Path, str::FromStr, env}; +use std::{env, path::Path, str::FromStr}; #[derive(Clone, Debug, Eq, PartialEq)] pub struct PluginBackoffInterval { @@ -281,18 +281,18 @@ impl ExecConfig { pub fn find_file() -> Result { let exec_file = "Exec.kdl"; - let mut curr_dir= env::current_dir().unwrap(); + let mut curr_dir = env::current_dir().unwrap(); loop { let target_path = curr_dir.join(exec_file); let target_ref = target_path.as_path(); if target_ref.exists() { // Parse found file log::info!("Using Exec Config at {:?}", target_ref); - return Self::from_file(target_ref) + return Self::from_file(target_ref); } if let Some(parent) = curr_dir.parent() { curr_dir = parent.to_path_buf(); - } else { + } else { // If file not found, use default values log::info!("Using a default Exec Config"); return Self::default(); diff --git a/hipcheck/src/session/mod.rs b/hipcheck/src/session/mod.rs index cec5e639..e35b19f3 100644 --- a/hipcheck/src/session/mod.rs +++ b/hipcheck/src/session/mod.rs @@ -307,23 +307,21 @@ fn load_exec_config(exec_path: Option<&Path>) -> Result { phase.enable_steady_tick(Duration::from_millis(100)); // Resolve the path to the exec config file. - let exec_config: ExecConfig; - - match exec_path { + let exec_config = match exec_path { Some(p) => { // Use the path provided if !p.exists() { hc_error!("Failed to load exec config. Please make sure the path set by the --exec flag exists."); } - exec_config = ExecConfig::from_file(p) + ExecConfig::from_file(p) .context("Failed to load the exec config. Please make sure the exec config file is in the provided location and is formatted correctly.") - .unwrap(); - }, + .unwrap() + } None => { // Search for file if not provided - exec_config = ExecConfig::find_file() + ExecConfig::find_file() .context("Failed to load the exec config. Please make sure the exec config file is in the provided location and is formatted correctly.") - .unwrap(); + .unwrap() } };