Use clap for git-mob
This commit is contained in:
parent
68e8e93bd0
commit
4de268ee20
|
|
@ -1,38 +1,38 @@
|
||||||
|
use clap::Parser;
|
||||||
use git_mob::{
|
use git_mob::{
|
||||||
ensure_commit_template_is_set, get_available_coauthors, get_main_author, set_main_author,
|
ensure_commit_template_is_set, get_available_coauthors, get_main_author, set_main_author,
|
||||||
with_gitmessage_template_path_or_exit, Author,
|
with_gitmessage_template_path_or_exit, Author,
|
||||||
};
|
};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process;
|
use std::process;
|
||||||
use structopt::StructOpt;
|
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[structopt(name="git-mob")]
|
#[clap(version, name = "git-mob")]
|
||||||
/// Assemble a group of co-authors to help you on your coding quest
|
/// Assemble a group of co-authors to help you on your coding quest
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// Prints list of available co-authors
|
/// Prints list of available co-authors
|
||||||
#[structopt(short, long)]
|
#[clap(short, long)]
|
||||||
list: bool,
|
list: bool,
|
||||||
/// Overwrite the main author
|
/// Overwrite the main author
|
||||||
#[structopt(short, long)]
|
#[clap(short, long)]
|
||||||
overwrite: Option<String>,
|
overwrite: Option<String>,
|
||||||
/// A list of co-author initials
|
/// A list of co-author initials
|
||||||
coauthors: Vec<String>,
|
coauthors: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let opt = Opt::from_args();
|
let args = Opt::parse();
|
||||||
|
|
||||||
if opt.list {
|
if args.list {
|
||||||
list_coauthors();
|
list_coauthors();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(initials) = opt.overwrite {
|
if let Some(initials) = args.overwrite {
|
||||||
override_main_author(&initials);
|
override_main_author(&initials);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_coauthors_to_gitmessage_file(&opt.coauthors);
|
write_coauthors_to_gitmessage_file(&args.coauthors);
|
||||||
ensure_commit_template_is_set();
|
ensure_commit_template_is_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue