feat: Ensure that arguments are correctly parsed

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

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

Loading…
Cancel
Save