| 115 | } |
| 116 | |
| 117 | fn 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 | } |