aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorTeddy Wing2020-08-29 15:07:36 +0200
committerTeddy Wing2020-08-29 19:33:19 +0200
commit8706dc07bcf3b4c965de8e9dd050bd8b97ebc693 (patch)
tree9a8582d5163a98ac4d85cd330199b4e4d1c819d6 /src/bin
parentf8aa7f6c8a632546b4cb234abf0030a39be52eed (diff)
downloadgit-suggestion-8706dc07bcf3b4c965de8e9dd050bd8b97ebc693.tar.bz2
git-sugdiff: Use `diff_options.parse()` to extract diff options
Config::get(): Change `args` type so we can pass both a `Vec<String>` 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.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/git-sugdiff.rs6
1 files changed, 6 insertions, 0 deletions
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] <suggestion>...",
@@ -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()