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

Function process_set_delete_args

lib/dsc-lib/src/dscresources/command_resource.rs:1014–1059  ·  view source on GitHub ↗

Process the arguments for a command resource's set or delete operation. # Arguments `args` - The Set/Delete arguments to process `value` - The value to use for JSON input arguments # Returns A vector of strings representing the processed arguments

(args: Option<&Vec<SetDeleteArgKind>>, input: &str, command_resource_info: &CommandResourceInfo, execution_type: &ExecutionKind)

Source from the content-addressed store, hash-verified

1012///
1013/// A vector of strings representing the processed arguments
1014fn process_set_delete_args(args: Option<&Vec<SetDeleteArgKind>>, input: &str, command_resource_info: &CommandResourceInfo, execution_type: &ExecutionKind) -> (Option<Vec<String>>, bool) {
1015 let Some(arg_values) = args else {
1016 debug!("{}", t!("dscresources.commandResource.noArgs"));
1017 return (None, false);
1018 };
1019
1020 let mut processed_args = Vec::<String>::new();
1021 let mut supports_whatif = false;
1022 for arg in arg_values {
1023 match arg {
1024 SetDeleteArgKind::String(s) => {
1025 processed_args.push(s.clone());
1026 },
1027 SetDeleteArgKind::Json { json_input_arg, mandatory } => {
1028 if input.is_empty() && *mandatory != Some(true) {
1029 continue;
1030 }
1031
1032 processed_args.push(json_input_arg.clone());
1033 processed_args.push(input.to_string());
1034 },
1035 SetDeleteArgKind::ResourcePath { resource_path_arg, include_quotes} => {
1036 if let Some(path) = &command_resource_info.path {
1037 processed_args.push(resource_path_arg.clone());
1038 if *include_quotes {
1039 processed_args.push(format!("\"{}\"", path.to_string_lossy()));
1040 } else {
1041 processed_args.push(path.to_string_lossy().to_string());
1042 }
1043 }
1044 },
1045 SetDeleteArgKind::ResourceType { resource_type_arg } => {
1046 processed_args.push(resource_type_arg.clone());
1047 processed_args.push(command_resource_info.type_name.to_string());
1048 },
1049 SetDeleteArgKind::WhatIf { what_if_arg } => {
1050 supports_whatif = true;
1051 if execution_type == &ExecutionKind::WhatIf {
1052 processed_args.push(what_if_arg.clone());
1053 }
1054 }
1055 }
1056 }
1057
1058 (Some(processed_args), supports_whatif)
1059}
1060
1061struct CommandInput {
1062 env: Option<HashMap<String, String>>,

Callers 2

invoke_setFunction · 0.85
invoke_deleteFunction · 0.85

Calls 2

newFunction · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected