Skip to content

Commit

Permalink
♻️ - Nest match instead of repeating
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandpeelen committed Jan 2, 2024
1 parent f18049e commit 29e9d23
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,29 @@ fn main() {
.filter
.map(|filter| Regex::new(filter.as_ref()).expect("Could not parse regex"));

match (lock::get(&folder), command) {
(lock::Lock::Error(ref e), _) => {
match (lock::get(&folder)) {

Check warning on line 60 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around `match` scrutinee expression

Check warning on line 60 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around `match` scrutinee expression
(lock::Lock::Error(ref e)) => {

Check warning on line 61 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern

Check warning on line 61 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern
eprintln!("Error while trying to get lock: {}", e.to_string());
std::process::exit(1)
}
(lock::Lock::Aquired(_), Command::Clean) => {
build::clean::clean(&folder);
}
(lock::Lock::Aquired(_), Command::Build) => {
match build::build(&filter, &folder, args.no_timing.unwrap_or(false)) {
Err(()) => std::process::exit(1),
Ok(_) => {
args.after_build.map(|command| cmd::run(command));
std::process::exit(0)
}
};
}
(lock::Lock::Aquired(_), Command::Watch) => {
let _initial_build = build::build(&filter, &folder, false);
args.after_build.clone().map(|command| cmd::run(command));
watcher::start(&filter, &folder, args.after_build);
}
(lock::Lock::Aquired(_)) => match command {

Check warning on line 65 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern

Check warning on line 65 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern
(Command::Clean) => {

Check warning on line 66 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern

Check warning on line 66 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern
build::clean::clean(&folder);
}
(Command::Build) => {

Check warning on line 69 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern

Check warning on line 69 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern
match build::build(&filter, &folder, args.no_timing.unwrap_or(false)) {
Err(()) => std::process::exit(1),
Ok(_) => {
args.after_build.map(|command| cmd::run(command));
std::process::exit(0)
}
};
}
(Command::Watch) => {

Check warning on line 78 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern

Check warning on line 78 in src/main.rs

View workflow job for this annotation

GitHub Actions / Run Tests

unnecessary parentheses around pattern
let _initial_build = build::build(&filter, &folder, false);
args.after_build.clone().map(|command| cmd::run(command));
watcher::start(&filter, &folder, args.after_build);
}
},
}
}

0 comments on commit 29e9d23

Please sign in to comment.