Skip to content

Commit

Permalink
feat: addapt file loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira committed Mar 29, 2024
1 parent 3d5c234 commit ecd43f4
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,23 @@ fn main() {
Args { cmd_init: true, .. } => execute(InitCommand::new(cli::watch::DEFAULT_FILENAME)),

Args { cmd_check: true, .. } => {
match rules::from_file(config_file) {
Ok(rules) => { rules::print_matches(rules, &args.arg_path); }
let rules = if args.flag_config.is_empty() {
let default_filename = cli::watch::DEFAULT_FILENAME;
match rules::from_file(default_filename) {
Ok(rules) => rules,
Err(err) => match rules::from_file(&default_filename.replace(".yaml", ".yml")) {
Ok(rules) => rules,
Err(_) => error("Failed to read default config file", err),
},
}
} else {
match rules::from_file(&args.flag_config) {
Ok(rules) => rules,
Err(err) => error("Failed to read config file", err),
}
};

Err(err) => error("Failed to read config file", err),
}
rules::print_matches(rules, &args.arg_path);
}

Args { arg_command, .. } if !arg_command.is_empty() => {
Expand Down

0 comments on commit ecd43f4

Please sign in to comment.