feat: Ensure that arguments are correctly parsed

pull/6/head
sgoudham 3 years ago
parent 5f0f2fff54
commit cdaab08594
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

@ -17,33 +17,47 @@ fn main() {
.author(crate_authors!()) .author(crate_authors!())
.about(crate_description!()) .about(crate_description!())
.long_about(None) .long_about(None)
.arg(Arg::new("branch").help("The branch to view git repository on")) .arg(
Arg::new("branch")
.help("The branch to view git repository on")
.short('b')
.long("branch")
.value_name("name")
.takes_value(true)
.display_order(2),
)
.arg( .arg(
Arg::new("remote") Arg::new("remote")
.help("The remote to view git repository on") .help("The remote to view git repository on")
.short('r') .short('r')
.long("remote") .long("remote")
.default_value("origin"), .value_name("name")
.takes_value(true)
.display_order(1),
) )
.arg( .arg(
Arg::new("commit") Arg::new("commit")
.help("Open Github on the current commit") .help("The commit to view git repository on")
.short('c') .short('c')
.long("commit") .long("commit")
.conflicts_with_all(&["remote", "branch"]), .value_name("hash")
.default_missing_value("latest")
.conflicts_with_all(&["remote", "branch"])
.display_order(3),
) )
.arg( .arg(
Arg::new("print") Arg::new("print")
.help("Only display the URL, does not open Github") .help("Print the URL (doesn't open browser)")
.short('p') .short('p')
.long("print"), .long("print")
.display_order(4),
); );
let matches = matches.get_matches(); let matches = matches.get_matches();
let mut git_view = GitView::new( let mut git_view = GitView::new(
matches.value_of("branch").map(str::to_string), matches.value_of("branch").map(str::to_string),
matches.value_of("remote").unwrap().to_string(), matches.value_of("remote").map(str::to_string),
matches.is_present("commit"), matches.value_of("commit").map(str::to_string),
matches.is_present("print"), matches.is_present("print"),
); );

Loading…
Cancel
Save