(flags: &[String])
| 80 | } |
| 81 | |
| 82 | pub fn parse_from_args(flags: &[String]) -> Result<Self, Box<dyn Error>> { |
| 83 | let app = make_options_parser(); |
| 84 | let matches = app.try_get_matches_from(flags.iter())?; |
| 85 | let detector_kind = match matches.value_of("kind") { |
| 86 | Some("deadlock") => DetectorKind::Deadlock, |
| 87 | Some("atomicity_violation") => DetectorKind::AtomicityViolation, |
| 88 | Some("memory") => DetectorKind::Memory, |
| 89 | Some("all") => DetectorKind::All, |
| 90 | Some("panic") => DetectorKind::Panic, |
| 91 | _ => return Err("UnsupportedDetectorKind")?, |
| 92 | }; |
| 93 | let black = matches.is_present("black"); |
| 94 | let crate_name_list = matches |
| 95 | .value_of("crates") |
| 96 | .map(|crates| { |
| 97 | let crates: Vec<String> = crates.split(',').map(|s| s.into()).collect(); |
| 98 | if black { |
| 99 | CrateNameList::Black(crates) |
| 100 | } else { |
| 101 | CrateNameList::White(crates) |
| 102 | } |
| 103 | }) |
| 104 | .unwrap_or_default(); |
| 105 | Ok(Options { |
| 106 | detector_kind, |
| 107 | crate_name_list, |
| 108 | }) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | #[cfg(test)] |
nothing calls this directly
no test coverage detected