MCPcopy Create free account
hub / github.com/PowerShell/DSC / require_input

Function require_input

resources/windows_service/src/main.rs:27–42  ·  view source on GitHub ↗

Deserialize the required JSON input into a `WindowsService`, or exit with an error.

(input_json: Option<String>)

Source from the content-addressed store, hash-verified

25
26/// Deserialize the required JSON input into a `WindowsService`, or exit with an error.
27fn 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.
45fn print_json(value: &impl serde::Serialize) {

Callers 1

mainFunction · 0.70

Calls 2

write_errorFunction · 0.70
from_strFunction · 0.50

Tested by

no test coverage detected