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/config.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index d8732d4..77793c4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,6 +15,7 @@ use std::env; +use std::ffi::OsStr; use std::process; use getopts::{self, Options}; @@ -57,7 +58,9 @@ pub struct Config { impl Config { /// Set up command line arguments. Extract configuration values from command /// line arguments, Git config, and environment variables. - pub fn get(args: &[String], usage_brief: &str) -> Result { + // pub fn get(args: C, usage_brief: &str) -> Result + // where C::Item: AsRef + pub fn get>(args: &[S], usage_brief: &str) -> Result { let mut opts = Options::new(); opts.optopt( -- cgit v1.2.3