diff options
author | Teddy Wing | 2020-08-29 15:07:36 +0200 |
---|---|---|
committer | Teddy Wing | 2020-08-29 19:33:19 +0200 |
commit | 8706dc07bcf3b4c965de8e9dd050bd8b97ebc693 (patch) | |
tree | 9a8582d5163a98ac4d85cd330199b4e4d1c819d6 /src/config.rs | |
parent | f8aa7f6c8a632546b4cb234abf0030a39be52eed (diff) | |
download | git-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/config.rs')
-rw-r--r-- | src/config.rs | 5 |
1 files changed, 4 insertions, 1 deletions
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<Self, Error> { + // pub fn get<C: IntoIterator>(args: C, usage_brief: &str) -> Result<Self, Error> + // where C::Item: AsRef<OsStr> + pub fn get<S: AsRef<OsStr>>(args: &[S], usage_brief: &str) -> Result<Self, Error> { let mut opts = Options::new(); opts.optopt( |