Deserialize the required JSON input into a `WindowsService`, or exit with an error.
(input_json: Option<String>)
| 25 | |
| 26 | /// Deserialize the required JSON input into a `WindowsService`, or exit with an error. |
| 27 | fn require_input(input_json: Option<String>) -> WindowsService { |
| 28 | let json = match input_json { |
| 29 | Some(j) => j, |
| 30 | None => { |
| 31 | write_error(&t!("main.missingInput")); |
| 32 | exit(EXIT_INVALID_ARGS); |
| 33 | } |
| 34 | }; |
| 35 | match serde_json::from_str(&json) { |
| 36 | Ok(v) => v, |
| 37 | Err(e) => { |
| 38 | write_error(&t!("main.invalidJson", error = e.to_string())); |
| 39 | exit(EXIT_INVALID_INPUT); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /// Serialize a value to JSON and print it to stdout, or exit with an error. |
| 45 | fn print_json(value: &impl serde::Serialize) { |
no test coverage detected