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

Function parse_input

resources/runcommandonset/src/utils.rs:30–53  ·  view source on GitHub ↗

Initialize `RunCommand` struct from input provided via stdin or via CLI arguments. # Arguments `arguments` - Optional arguments to pass to the command `executable` - The command to execute `exit_code` - The expected exit code upon success, if non-zero `stdin` - Optional JSON or YAML input provided via stdin # Errors Error message then exit if the `RunCommand` struct cannot be initialized from

(arguments: Option<Vec<String>>, executable: Option<String>, exit_code: i32, stdin: Option<String>)

Source from the content-addressed store, hash-verified

28///
29/// Error message then exit if the `RunCommand` struct cannot be initialized from the provided inputs.
30pub fn parse_input(arguments: Option<Vec<String>>, executable: Option<String>, exit_code: i32, stdin: Option<String>) -> runcommand::RunCommand {
31 let command: runcommand::RunCommand;
32 if let Some(input) = stdin {
33 debug!("Input: {}", input);
34 command = match serde_json::from_str(&input) {
35 Ok(json) => json,
36 Err(err) => {
37 error!("{}: {err}", t!("utils.invalidInput"));
38 exit(EXIT_INVALID_INPUT);
39 }
40 }
41 } else if let Some(executable) = executable {
42 command = runcommand::RunCommand {
43 executable,
44 arguments,
45 exit_code,
46 };
47 }
48 else {
49 error!("{}", t!("utils.executableRequired"));
50 exit(EXIT_INVALID_INPUT);
51 }
52 command
53}
54
55/// Setup tracing subscriber based on the provided trace level and format.
56///

Callers 1

mainFunction · 0.85

Calls 1

from_strFunction · 0.50

Tested by

no test coverage detected