@@ -271,15 +271,16 @@ fn initialize_config_root(path: Option<&String>) -> Option<String> {
271
271
}
272
272
273
273
#[ allow( clippy:: too_many_lines) ]
274
- pub fn config ( subcommand : & ConfigSubCommand , parameters : & Option < String > , mounted_path : Option < & String > , as_group : & bool , as_assert : & bool , as_include : & bool , progress_format : ProgressFormat ) {
274
+ #[ allow( clippy:: too_many_arguments) ]
275
+ pub fn config ( subcommand : & ConfigSubCommand , parameters : & Option < String > , parameters_from_stdin : bool , mounted_path : Option < & String > , as_group : & bool , as_assert : & bool , as_include : & bool , progress_format : ProgressFormat ) {
275
276
let ( new_parameters, json_string) = match subcommand {
276
277
ConfigSubCommand :: Get { input, file, .. } |
277
278
ConfigSubCommand :: Set { input, file, .. } |
278
279
ConfigSubCommand :: Test { input, file, .. } |
279
280
ConfigSubCommand :: Validate { input, file, .. } |
280
281
ConfigSubCommand :: Export { input, file, .. } => {
281
282
let new_path = initialize_config_root ( file. as_ref ( ) ) ;
282
- let document = get_input ( input. as_ref ( ) , new_path. as_ref ( ) ) ;
283
+ let document = get_input ( input. as_ref ( ) , new_path. as_ref ( ) , parameters_from_stdin ) ;
283
284
if * as_include {
284
285
let ( new_parameters, config_json) = match get_contents ( & document) {
285
286
Ok ( ( parameters, config_json) ) => ( parameters, config_json) ,
@@ -295,7 +296,7 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, mounte
295
296
} ,
296
297
ConfigSubCommand :: Resolve { input, file, .. } => {
297
298
let new_path = initialize_config_root ( file. as_ref ( ) ) ;
298
- let document = get_input ( input. as_ref ( ) , new_path. as_ref ( ) ) ;
299
+ let document = get_input ( input. as_ref ( ) , new_path. as_ref ( ) , parameters_from_stdin ) ;
299
300
let ( new_parameters, config_json) = match get_contents ( & document) {
300
301
Ok ( ( parameters, config_json) ) => ( parameters, config_json) ,
301
302
Err ( err) => {
@@ -391,7 +392,7 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, mounte
391
392
} ;
392
393
if * as_include {
393
394
let new_path = initialize_config_root ( file. as_ref ( ) ) ;
394
- let input = get_input ( input. as_ref ( ) , new_path. as_ref ( ) ) ;
395
+ let input = get_input ( input. as_ref ( ) , new_path. as_ref ( ) , parameters_from_stdin ) ;
395
396
match serde_json:: from_str :: < Include > ( & input) {
396
397
Ok ( _) => {
397
398
// valid, so do nothing
@@ -582,40 +583,36 @@ pub fn resource(subcommand: &ResourceSubCommand, progress_format: ProgressFormat
582
583
} ,
583
584
ResourceSubCommand :: Export { resource, input, file, output_format } => {
584
585
dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format) ;
585
- let parsed_input = get_input ( input. as_ref ( ) , file. as_ref ( ) ) ;
586
+ let parsed_input = get_input ( input. as_ref ( ) , file. as_ref ( ) , false ) ;
586
587
resource_command:: export ( & mut dsc, resource, & parsed_input, output_format. as_ref ( ) ) ;
587
588
} ,
588
589
ResourceSubCommand :: Get { resource, input, file : path, all, output_format } => {
589
590
dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format) ;
590
- if * all { resource_command:: get_all ( & dsc, resource, output_format. as_ref ( ) ) ; }
591
+ if * all {
592
+ resource_command:: get_all ( & dsc, resource, output_format. as_ref ( ) ) ;
593
+ }
591
594
else {
592
- let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
593
- let format = match output_format {
594
- Some ( GetOutputFormat :: Json ) => Some ( OutputFormat :: Json ) ,
595
- Some ( GetOutputFormat :: JsonArray ) => {
596
- error ! ( "{}" , t!( "subcommand.jsonArrayNotSupported" ) ) ;
597
- exit ( EXIT_INVALID_ARGS ) ;
598
- } ,
599
- Some ( GetOutputFormat :: PrettyJson ) => Some ( OutputFormat :: PrettyJson ) ,
600
- Some ( GetOutputFormat :: Yaml ) => Some ( OutputFormat :: Yaml ) ,
601
- None => None ,
602
- } ;
603
- resource_command:: get ( & dsc, resource, & parsed_input, format. as_ref ( ) ) ;
595
+ if * output_format == Some ( GetOutputFormat :: JsonArray ) {
596
+ error ! ( "{}" , t!( "subcommand.jsonArrayNotSupported" ) ) ;
597
+ exit ( EXIT_INVALID_ARGS ) ;
598
+ }
599
+ let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) , false ) ;
600
+ resource_command:: get ( & dsc, resource, & parsed_input, output_format. as_ref ( ) ) ;
604
601
}
605
602
} ,
606
603
ResourceSubCommand :: Set { resource, input, file : path, output_format } => {
607
604
dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format) ;
608
- let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
605
+ let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) , false ) ;
609
606
resource_command:: set ( & dsc, resource, & parsed_input, output_format. as_ref ( ) ) ;
610
607
} ,
611
608
ResourceSubCommand :: Test { resource, input, file : path, output_format } => {
612
609
dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format) ;
613
- let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
610
+ let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) , false ) ;
614
611
resource_command:: test ( & dsc, resource, & parsed_input, output_format. as_ref ( ) ) ;
615
612
} ,
616
613
ResourceSubCommand :: Delete { resource, input, file : path } => {
617
614
dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format) ;
618
- let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
615
+ let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) , false ) ;
619
616
resource_command:: delete ( & dsc, resource, & parsed_input) ;
620
617
} ,
621
618
}
0 commit comments