diff --git a/README.md b/README.md index 387fe93..36dc836 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,11 @@ Options: -l, --language Game Language [default: en_US] -d, --depth - Depth to walk folder structure [env: DEPTH=] [default: 3] + Depth to walk folder structure [env: DEPTH=] [default: 5] -s, --skip-installed - Compare against installed weidu log, note this is best effort [env: SKIP_INSTALLED=] + Compare against installed weidu log, note this is best effort [env: SKIP_INSTALLED=] [default: true] -a, --abort-on-warnings - If a warning occurs in the weidu child process exit [env: ABORT_ON_WARNINGS=] + If a warning occurs in the weidu child process exit, note this is best effort [env: ABORT_ON_WARNINGS=] [default: true] -t, --timeout Timeout time per mod in seconds, default is 1 hour [env: TIMEOUT=] [default: 3600] -u, --weidu-log-mode diff --git a/src/args.rs b/src/args.rs index 3e5e100..a47d271 100644 --- a/src/args.rs +++ b/src/args.rs @@ -42,7 +42,7 @@ pub struct Args { pub language: String, /// Depth to walk folder structure - #[clap(env, long, short, default_value = "3")] + #[clap(env, long, short, default_value = "5")] pub depth: usize, /// Compare against installed weidu log, note this is best effort diff --git a/src/weidu_parser.rs b/src/weidu_parser.rs index c744ed1..9298945 100644 --- a/src/weidu_parser.rs +++ b/src/weidu_parser.rs @@ -21,14 +21,9 @@ const WEIDU_USEFUL_STATUS: [&str; 9] = [ "processing", ]; -const WEIDU_CHOICE: [&str; 6] = [ - "choice", - "choose", - "select", - "do you want", - "would you like", - "enter", -]; +const WEIDU_CHOICE_WORDS: [&str; 4] = ["choice", "choose", "select", "enter"]; + +const WEIDU_CHOICE_PHRASE: [&str; 2] = ["do you want", "would you like"]; const WEIDU_COMPLETED_WITH_WARNINGS: &str = "installed with warnings"; @@ -139,11 +134,27 @@ fn string_looks_like_question(weidu_output: &str) -> bool { { return false; } - return WEIDU_CHOICE - .iter() - .map(|choice| comparable_output.contains(choice)) - .reduce(|a, b| a | b) - .unwrap_or(false); + + for question in WEIDU_CHOICE_PHRASE { + if comparable_output.contains(question) { + return true; + } + } + + for question in WEIDU_CHOICE_WORDS { + for word in comparable_output.split_whitespace() { + if word + .chars() + .filter(|c| c.is_alphabetic()) + .collect::() + == question + { + return true; + } + } + } + + false } fn detect_weidu_finished_state(weidu_output: &str) -> Option { @@ -186,7 +197,9 @@ mod tests { #[test] fn is_not_question() { let test = "Creating epilogues. Too many epilogues... Why are there so many options here?"; - assert_eq!(string_looks_like_question(test), false) + assert_eq!(string_looks_like_question(test), false); + let test = "Including file(s) spellchoices_defensive/vanilla/ENCHANTER.TPH"; + assert_eq!(string_looks_like_question(test), false); } #[test]