aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-08-30 01:44:25 +0200
committerTeddy Wing2020-08-30 01:44:25 +0200
commitd9b8838a5d99e643a751d042047644cfa4a9a032 (patch)
treee851b46a5d244ee3413311f3db8330aad0c0b10a
parent905594dc8393f97c1a960d639af46175b3e6b76f (diff)
downloadgit-suggestion-d9b8838a5d99e643a751d042047644cfa4a9a032.tar.bz2
diff_options: Merge `ARG_OPTIONS` and `OPT_OPTIONS`
Now that I've confirmed that Git's key value options require an '=' to specify the value, we can drop the distinction between options that require and argument and those that optionally take an argument. Also remove the code that interprets an argument that doesn't start with '-' as the value of the preceding option.
-rw-r--r--src/diff_options.rs31
1 files changed, 2 insertions, 29 deletions
diff --git a/src/diff_options.rs b/src/diff_options.rs
index a35acfd..55b76ce 100644
--- a/src/diff_options.rs
+++ b/src/diff_options.rs
@@ -76,7 +76,7 @@ static FLAGS: [&'static str; 59] = [
"--ita-invisible-in-index",
];
-static ARG_OPTIONS: [&'static str; 20] = [
+static OPTIONS: [&'static str; 39] = [
"-U",
"--unified",
"--output",
@@ -97,9 +97,6 @@ static ARG_OPTIONS: [&'static str; 20] = [
"--src-prefix",
"--dst-prefix",
"--line-prefix",
-];
-
-static OPT_OPTIONS: [&'static str; 19] = [
"--stat",
"-X",
"--dirstat",
@@ -125,24 +122,8 @@ static OPT_OPTIONS: [&'static str; 19] = [
pub fn parse(args: &[String]) -> (Vec<&String>, Vec<&String>) {
let mut program_args = Vec::new();
let mut found_args = Vec::new();
- let mut add_next_arg = false;
'args: for arg in args {
- let find_arg_prefix = arg.find('-');
-
- if add_next_arg
- && (
- find_arg_prefix.is_none()
- || find_arg_prefix != Some(0)
- )
- {
- found_args.push(arg);
-
- add_next_arg = false;
-
- continue;
- }
-
for flag in FLAGS.iter() {
if arg.starts_with(flag) {
found_args.push(arg);
@@ -151,15 +132,7 @@ pub fn parse(args: &[String]) -> (Vec<&String>, Vec<&String>) {
}
}
- for option in &ARG_OPTIONS {
- if arg.starts_with(option) {
- found_args.push(arg);
-
- continue 'args;
- }
- }
-
- for option in &OPT_OPTIONS {
+ for option in OPTIONS.iter() {
if arg.starts_with(option) {
found_args.push(arg);