Skip to content

Commit

Permalink
fix(exit): Exit if successs found
Browse files Browse the repository at this point in the history
Signed-off-by: dark0dave <[email protected]>
  • Loading branch information
dark0dave committed Dec 2, 2023
1 parent 9b16e85 commit dbb54ca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/weidu_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const WEIDU_COMPLETED_WITH_WARNINGS: &str = "installed with warnings";

const WEIDU_FAILED_WITH_ERROR: &str = "not installed due to errors";

const WEIDU_FINISHED: &str = "successfully installed";

#[derive(Debug)]
enum ParserState {
CollectingQuestion,
Expand Down Expand Up @@ -99,6 +101,7 @@ pub fn parse_raw_output(sender: Sender<State>, receiver: Receiver<String>) {
question = String::new();
}
_ => {
// TODO: Exit here if we come here too much
// there is no new weidu output and we are not waiting for any, so there is nothing to do
}
}
Expand Down Expand Up @@ -137,6 +140,8 @@ fn detect_weidu_finished_state(weidu_output: &str) -> Option<State> {
})
} else if comparable_output.contains(WEIDU_COMPLETED_WITH_WARNINGS) {
Some(State::CompletedWithWarnings)
} else if comparable_output.contains(WEIDU_FINISHED) {
Some(State::Completed)
} else {
None
}
Expand All @@ -153,4 +158,9 @@ mod tests {
Some(State::CompletedWithWarnings)
)
}
#[test]
fn test_exit_success() {
let test = "SUCCESSFULLY INSTALLED Jan's Extended Quest";
assert_eq!(detect_weidu_finished_state(test), Some(State::Completed))
}
}

0 comments on commit dbb54ca

Please sign in to comment.