1#![deny(warnings)]
2
3extern crate clap;
4
5extern crate regex;
6
7pub mod cli;
8
9use clap::ArgMatches;
10
11mod branches;
12use branches::Branches;
13
14mod commands;
15pub use commands::validate_git_installation;
16
17mod error;
18use error::Error;
19
20mod options;
21use options::Options;
22
23pub fn run(matches: &ArgMatches) -> Result<(), error::Error> {
24 validate_git_installation()?;
25
26 let options = Options::new(matches);
27 options.validate()?;
28
29 let branches = Branches::merged(&options);
30
31 if branches.string.is_empty() {
32 println!("No branches to delete, you're clean!");
33 return Ok(());
34 }
35
36 if !matches.is_present("yes") {
37 branches.print_warning_and_prompt(&options.delete_mode)?;
38 }
39
40 let msg = branches.delete(&options);
41 println!("\n{}", msg);
42
43 Ok(())
44}
45
46pub fn print_and_exit(error: &Error) {
47 println!("{}", error);
48 std::process::exit(1);
49}