@@ -5,7 +5,7 @@ use crate::args::{ConfigSubCommand, DscType, OutputFormat, ResourceSubCommand};
55use crate :: resolve:: { get_contents, Include } ;
66use crate :: resource_command:: { get_resource, self } ;
77use crate :: tablewriter:: Table ;
8- use crate :: util:: { DSC_CONFIG_ROOT , EXIT_DSC_ERROR , EXIT_INVALID_INPUT , EXIT_JSON_ERROR , get_schema, write_output, get_input, set_dscconfigroot, validate_json} ;
8+ use crate :: util:: { DSC_CONFIG_ROOT , EXIT_DSC_ERROR , EXIT_INVALID_ARGS , EXIT_INVALID_INPUT , EXIT_JSON_ERROR , get_schema, write_output, get_input, set_dscconfigroot, validate_json} ;
99use dsc_lib:: configure:: { Configurator , config_doc:: { Configuration , ExecutionKind } , config_result:: ResourceGetResult } ;
1010use dsc_lib:: dscerror:: DscError ;
1111use dsc_lib:: dscresources:: invoke_result:: ResolveResult ;
@@ -15,9 +15,12 @@ use dsc_lib::{
1515 dscresources:: dscresource:: { Capability , ImplementedAs , Invoke } ,
1616 dscresources:: resource_manifest:: { import_manifest, ResourceManifest } ,
1717} ;
18- use std:: collections:: HashMap ;
19- use std:: io:: { self , IsTerminal } ;
20- use std:: process:: exit;
18+ use std:: {
19+ collections:: HashMap ,
20+ io:: { self , IsTerminal } ,
21+ path:: Path ,
22+ process:: exit
23+ } ;
2124use tracing:: { debug, error, trace} ;
2225
2326pub fn config_get ( configurator : & mut Configurator , format : & Option < OutputFormat > , as_group : & bool )
@@ -186,7 +189,7 @@ fn initialize_config_root(path: &Option<String>) -> Option<String> {
186189}
187190
188191#[ allow( clippy:: too_many_lines) ]
189- pub fn config ( subcommand : & ConfigSubCommand , parameters : & Option < String > , stdin : & Option < String > , as_group : & bool , as_include : & bool ) {
192+ pub fn config ( subcommand : & ConfigSubCommand , parameters : & Option < String > , mounted_path : & Option < String > , stdin : & Option < String > , as_group : & bool , as_include : & bool ) {
190193 let ( new_parameters, json_string) = match subcommand {
191194 ConfigSubCommand :: Get { document, path, .. } |
192195 ConfigSubCommand :: Set { document, path, .. } |
@@ -270,6 +273,15 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, stdin:
270273 }
271274 } ;
272275
276+ if let Some ( path) = mounted_path {
277+ if !Path :: new ( & path) . exists ( ) {
278+ error ! ( "Error: Target path '{path}' does not exist" ) ;
279+ exit ( EXIT_INVALID_ARGS ) ;
280+ }
281+
282+ configurator. set_system_root ( path) ;
283+ }
284+
273285 if let Err ( err) = configurator. set_context ( & parameters) {
274286 error ! ( "Error: Parameter input failure: {err}" ) ;
275287 exit ( EXIT_INVALID_INPUT ) ;
0 commit comments