Skip to content

Commit

Permalink
fix: some clippy errors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
pvshvp-oss committed May 12, 2024
1 parent f7eec38 commit 6bc0607
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
17 changes: 5 additions & 12 deletions paxy/src/actions/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ macro_rules! home {

#[inline]
pub fn ensure_path(path: Option<&PathBuf>) {
if path.is_none() {
if let Some(path) = path {
if !path.is_dir() {
::std::fs::create_dir_all(path.clone()).expect("Inufficient permissions");
}
} else {
let mut file = home!();
file.push(".paxy");
if !file.is_dir() {
::std::fs::create_dir_all(file).expect("Inufficient permissions");
}
} else {
if !path
.unwrap()
.is_dir()
{
::std::fs::create_dir_all(
path.unwrap()
.clone(),
)
.expect("Inufficient permissions");
}
}
}

Expand Down
16 changes: 3 additions & 13 deletions paxy/src/app/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn init_config<G: GlobalArguments>(
config = config.with_overriding_files(&config_filepaths);

// Merge configuration values from environment variables
config = config.with_overriding_env(&format!("{}_", *app::APP_NAME));
config = config.with_overriding_env(format!("{}_", *app::APP_NAME));

// Merge configuration values from the CLI
config = config.with_overriding_args(&console_global_arguments);
Expand All @@ -44,7 +44,7 @@ pub fn init_config<G: GlobalArguments>(
.figment
.admerge(("log_dirpath", &log_dirpath));

Ok(config.object()?)
config.object()
}

fn candidate_config_filepaths() -> Result<Vec<PathBuf>, Error> {
Expand Down Expand Up @@ -119,23 +119,13 @@ fn fallback_log_dirpath() -> Result<PathBuf, Error> {
.to_owned())
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ConfigTemplate {
pub config_filepaths: Vec<PathBuf>,
pub log_dirpath: PathBuf,
pub console_output_format: ui::ConsoleOutputFormat,
}

impl Default for ConfigTemplate {
fn default() -> Self {
Self {
config_filepaths: Vec::new(),
log_dirpath: PathBuf::default(),
console_output_format: ui::ConsoleOutputFormat::default(),
}
}
}

// Make `ConfigTemplate` a provider itself for composability.
impl figment::Provider for ConfigTemplate {
fn metadata(&self) -> figment::Metadata {
Expand Down
9 changes: 2 additions & 7 deletions paxy/src/app/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,15 @@ impl ConsoleOutputFormat {
}
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ConsoleOutputMode {
#[default]
Regular,
Plain,
Json,
Test,
}

impl Default for ConsoleOutputMode {
fn default() -> Self {
ConsoleOutputMode::Regular
}
}

pub trait GlobalArguments {
fn config_filepath(&self) -> &Option<PathBuf>;

Expand Down

0 comments on commit 6bc0607

Please sign in to comment.