You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
3 years ago
|
use clap::Parser;
|
||
|
|
||
|
mod vcs;
|
||
|
|
||
|
use vcs::cli::*;
|
||
|
|
||
|
fn main() {
|
||
|
let args = Cli::parse();
|
||
|
|
||
|
let work_dir = args
|
||
|
.path
|
||
|
.unwrap_or_else(|| std::env::current_dir().expect("Unable to obtain current_dir"));
|
||
|
let mut vcs = match vcs::Vcs::new(work_dir) {
|
||
|
Ok(val) => val,
|
||
|
Err(err) => {
|
||
|
eprintln!("{}", err);
|
||
|
std::process::exit(err.exit_code());
|
||
|
}
|
||
|
};
|
||
|
|
||
|
match args.command {
|
||
|
Commands::Branch(BranchCommand::Set { branch }) => {
|
||
|
vcs.set_branch(&branch)
|
||
|
.expect("Error setting branch on projects");
|
||
|
}
|
||
|
Commands::Profile(ProfileCommand::Save { profile }) => {
|
||
|
vcs.save_profile(&profile)
|
||
|
.expect("Error saving vcs profile");
|
||
|
}
|
||
|
Commands::Profile(ProfileCommand::Set { profile }) => {
|
||
|
vcs.set_profile(&profile)
|
||
|
.expect("Error setting vcs profile");
|
||
|
}
|
||
|
Commands::Status { verbose } => {
|
||
|
if verbose {
|
||
|
vcs.list();
|
||
|
} else {
|
||
|
vcs.info().expect("Error summarizing info");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|