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

Function process_import_args

lib/dsc-lib/src/extensions/import.rs:117–144  ·  view source on GitHub ↗
(args: Option<&Vec<ImportArgKind>>, file: &Path)

Source from the content-addressed store, hash-verified

115}
116
117fn process_import_args(args: Option<&Vec<ImportArgKind>>, file: &Path) -> Result<Option<Vec<String>>, DscError> {
118 let Some(arg_values) = args else {
119 debug!("{}", t!("dscresources.commandResource.noArgs"));
120 return Ok(None);
121 };
122
123 // make path absolute
124 let Ok(full_path) = file.absolutize() else {
125 return Err(DscError::Extension(t!("util.failedToAbsolutizePath", path = file.display()).to_string()));
126 };
127
128 let mut processed_args = Vec::<String>::new();
129 for arg in arg_values {
130 match arg {
131 ImportArgKind::String(s) => {
132 processed_args.push(s.clone());
133 },
134 ImportArgKind::File { file_arg } => {
135 if !file_arg.is_empty() {
136 processed_args.push(file_arg.to_string());
137 }
138 processed_args.push(full_path.to_string_lossy().to_string());
139 },
140 }
141 }
142
143 Ok(Some(processed_args))
144}

Callers 1

importMethod · 0.85

Calls 2

newFunction · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected