From 905594dc8393f97c1a960d639af46175b3e6b76f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 30 Aug 2020 01:20:33 +0200 Subject: diff_options: Clean up code Remove old process code and comments. --- src/bin/git-sugdiff.rs | 5 -- src/config.rs | 2 - src/diff_options.rs | 176 ------------------------------------------------- 3 files changed, 183 deletions(-) diff --git a/src/bin/git-sugdiff.rs b/src/bin/git-sugdiff.rs index ab893f0..62bec8f 100644 --- a/src/bin/git-sugdiff.rs +++ b/src/bin/git-sugdiff.rs @@ -28,12 +28,7 @@ use github_suggestion_cli::diff_options; fn main() { let args: Vec<_> = env::args().collect(); - // 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, diff --git a/src/config.rs b/src/config.rs index 77793c4..c76abf3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -58,8 +58,6 @@ 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: C, usage_brief: &str) -> Result - // where C::Item: AsRef pub fn get>(args: &[S], usage_brief: &str) -> Result { let mut opts = Options::new(); diff --git a/src/diff_options.rs b/src/diff_options.rs index 108fc13..a35acfd 100644 --- a/src/diff_options.rs +++ b/src/diff_options.rs @@ -76,48 +76,6 @@ static FLAGS: [&'static str; 59] = [ "--ita-invisible-in-index", ]; -// static OPTIONS: [&'static str; 21] = [ -// "-U", -// "--unified=", -// "--output=", -// "--output-indicator-new=", -// "--output-indicator-old=", -// "--output-indicator-context=", -// "--anchored=", -// "--diff-algorithm={patience|minimal|histogram|myers}", -// "--stat[=[,[,]]]", -// "-X[]", -// "--dirstat[=]", -// "--dirstat-by-file[=...]", -// "--submodule[=]", -// "--color[=]", -// "--color-moved[=]", -// "--color-moved-ws=", -// "--word-diff[=]", -// "--word-diff-regex=", -// "--color-words[=]", -// "--ws-error-highlight=", -// "--abbrev[=]", -// "-B[][/]", -// "--break-rewrites[=[][/]]", -// "-M[]", -// "--find-renames[=]", -// "-C[]", -// "--find-copies[=]", -// "-l", -// "--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]", -// "-S", -// "-G", -// "--find-object=", -// "-O", -// "--relative[=]", -// "--inter-hunk-context=", -// "--ignore-submodules[=]", -// "--src-prefix=", -// "--dst-prefix=", -// "--line-prefix=", -// ]; - static ARG_OPTIONS: [&'static str; 20] = [ "-U", "--unified", @@ -164,7 +122,6 @@ static OPT_OPTIONS: [&'static str; 19] = [ ]; -// pub fn parse(args: &[String]) -> &[String] { pub fn parse(args: &[String]) -> (Vec<&String>, Vec<&String>) { let mut program_args = Vec::new(); let mut found_args = Vec::new(); @@ -173,7 +130,6 @@ pub fn parse(args: &[String]) -> (Vec<&String>, Vec<&String>) { 'args: for arg in args { let find_arg_prefix = arg.find('-'); - // TODO: Ignore suggestion args if add_next_arg && ( find_arg_prefix.is_none() @@ -195,55 +151,22 @@ pub fn parse(args: &[String]) -> (Vec<&String>, Vec<&String>) { } } - // TODO: check for "=" and get next arg - // '=' - // if no equals, then add next arg - // Turns out values are always specified with '=' for option in &ARG_OPTIONS { if arg.starts_with(option) { found_args.push(arg); - // if arg doesn't have an = after it - // if i < arg.len() { - // let char_after_option = arg.get(option.len()); - // if char_after_option.is_some() - // && char_after_option.unwrap() == '=' { - - let (_option, rest) = arg.split_at(option.len()); - - dbg!(arg); - dbg!(arg.len()); - dbg!(option); - dbg!(option.len()); - dbg!(rest.find('=').is_none()); - // if arg.len() > option.len() - // && rest.find('=').is_none() { - // if rest.find('=').is_none() { - // add_next_arg = true; - // } - continue 'args; } } - // check '=' - // If no equals, add next arg if it doesn't begin with '-' - // OptOptions are always followed by '=' when specifying values for option in &OPT_OPTIONS { if arg.starts_with(option) { found_args.push(arg); - // let (_option, rest) = arg.split_at(option.len()); - // - // if rest.find('=').is_none() { - // add_next_arg = true; - // } - continue 'args; } } - // TODO: Otherwise, add to normal arguments list program_args.push(arg) } @@ -309,102 +232,3 @@ mod tests { ]); } } - -// -p -// --no-stat -// -p -// -u -// --patch -// -s -// --no-patch -// -U -// --unified= -// --output= -// --output-indicator-new= -// --output-indicator-old= -// --output-indicator-context= -// --raw -// --patch-with-raw -// -t -// --indent-heuristic -// --no-indent-heuristic -// --minimal -// --patience -// --histogram -// --anchored= -// --diff-algorithm={patience|minimal|histogram|myers} -// --stat[=[,[,]]] -// --compact-summary -// --numstat -// --shortstat -// -X[] -// --dirstat[=] -// --cumulative -// --dirstat-by-file[=...] -// --summary -// --patch-with-stat -// -z -// --name-only -// --name-status -// --submodule[=] -// --color[=] -// --no-color -// --color-moved[=] -// --no-color-moved -// --color-moved-ws= -// --no-color-moved-ws -// --word-diff[=] -// --word-diff-regex= -// --color-words[=] -// --no-renames -// --[no-]rename-empty -// --check -// --ws-error-highlight= -// --full-index -// --binary -// --abbrev[=] -// -B[][/] -// --break-rewrites[=[][/]] -// -M[] -// --find-renames[=] -// -C[] -// --find-copies[=] -// --find-copies-harder -// -D -// --irreversible-delete -// -l -// --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]] -// -S -// -G -// -S"frotz\(nitfol" --pickaxe-regex` will not (because the number of -// --find-object= -// --pickaxe-all -// --pickaxe-regex -// -O -// -R -// --relative[=] -// --no-relative -// -a -// --text -// --ignore-cr-at-eol -// --ignore-space-at-eol -// -b -// --ignore-space-change -// -w -// --ignore-all-space -// --ignore-blank-lines -// --inter-hunk-context= -// -W -// --function-context -// --exit-code -// --quiet -// --ext-diff -// --no-ext-diff -// --textconv -// --no-textconv -// --ignore-submodules[=] -// --src-prefix= -// --dst-prefix= -// --no-prefix -// --line-prefix= -// --ita-invisible-in-index -- cgit v1.2.3