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 d64c7aa commit dc0ffef
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ 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) {
lock::Lock::Error(ref e) => {
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 {
Command::Clean => build::clean::clean(&folder),
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)
}
};
}
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);
}
},
}
}

0 comments on commit dc0ffef

Please sign in to comment.