Skip to content

Commit

Permalink
fix clippy issue
Browse files Browse the repository at this point in the history
  • Loading branch information
timopruesse committed Jun 8, 2022
1 parent 09f81c7 commit adcd08f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions src/config/base_config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use crate::utils::shell::Shell;

use super::{config_value::ConfigValue, json_config::JsonConfig, yaml_config::YamlConfig};
use super::{
config_value::ConfigValue,
json_config::JsonConfig,
yaml_config::{YamlConfig, ALLOWED_EXTENSIONS},
};

#[derive(Debug)]
pub struct Command {
Expand Down Expand Up @@ -28,11 +32,11 @@ pub trait BaseConfig {
fn get_config_handler(config_path: &str) -> Result<Box<dyn BaseConfig>, String> {
let file_ending = config_path.split('.').last().unwrap();

return match file_ending {
file_ending if file_ending == "yml" || file_ending == "yaml" => Ok(Box::new(YamlConfig {})),
file_ending if file_ending == "json" => Ok(Box::new(JsonConfig {})),
_ => Err(format!("Unsupported config file format: .{}", file_ending)),
};
match file_ending {
file_ending if ALLOWED_EXTENSIONS.contains(&file_ending) => Ok(Box::new(YamlConfig {})),
"json" => Ok(Box::new(JsonConfig {})),
_ => Err(format!("Unsupported config file type: {}", file_ending)),
}
}

pub fn get_config(config_path: &str) -> Result<TaskList, String> {
Expand Down
2 changes: 1 addition & 1 deletion src/config/yaml_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::config_value::ConfigValue;
#[derive(Debug)]
pub struct YamlConfig {}

static ALLOWED_EXTENSIONS: [&str; 2] = ["yml", "yaml"];
pub static ALLOWED_EXTENSIONS: [&str; 2] = ["yml", "yaml"];

fn convert_to_config_value(yaml: &Yaml) -> ConfigValue {
match yaml {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use terminal::terminal::execute_command;
use terminal::command::execute_command;

pub mod command;
pub mod commands;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/terminal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod cli;
pub mod terminal;
pub mod command;

0 comments on commit adcd08f

Please sign in to comment.