From 8706dc07bcf3b4c965de8e9dd050bd8b97ebc693 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 29 Aug 2020 15:07:36 +0200 Subject: git-sugdiff: Use `diff_options.parse()` to extract diff options Config::get(): Change `args` type so we can pass both a `Vec` and `Vec<&String>`. diff_options.parse(): * Split diff arguments and program arguments by returning a tuple. * Exit the args loop once we've parsed an argument. * Update test * Add a non-working test for suggestion arguments. An `OPT_OPTIONS` argument could be followed by an argument that's not the value of the `OPT_OPTIONS` option. Currently, that arg will always be parsed as the value. We need to handle this case. --- src/bin/git-sugdiff.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/bin/git-sugdiff.rs') diff --git a/src/bin/git-sugdiff.rs b/src/bin/git-sugdiff.rs index 6b95239..13c3292 100644 --- a/src/bin/git-sugdiff.rs +++ b/src/bin/git-sugdiff.rs @@ -22,6 +22,7 @@ use exitcode; use github_suggestion_cli::{gseprintln, for_suggestion}; use github_suggestion_cli::config::Config; +use github_suggestion_cli::diff_options; fn main() { @@ -30,6 +31,10 @@ fn main() { // TODO: Shift all diff options from args, then pass them to Config::get(). // Add diff options to Command call below. + let (args, diff_args) = diff_options::parse(&args); + dbg!(&args); + dbg!(&diff_args); + let config = match Config::get( &args, "usage: git sugdiff [options] ...", @@ -56,6 +61,7 @@ fn main() { match Command::new("git") .arg("--no-pager") .arg("diff") + .args(&diff_args) .arg(format!("{}:{}", suggestion.commit(), suggestion.path())) .arg(blob.to_string()) .spawn() -- cgit v1.2.3