@@ -25,6 +25,7 @@ use dsc_lib::{
25
25
} ,
26
26
dscresources:: dscresource:: { Capability , ImplementedAs , Invoke } ,
27
27
dscresources:: resource_manifest:: { import_manifest, ResourceManifest } ,
28
+ util:: ProgressFormat ,
28
29
} ;
29
30
use rust_i18n:: t;
30
31
use std:: {
@@ -251,7 +252,7 @@ fn initialize_config_root(path: Option<&String>) -> Option<String> {
251
252
}
252
253
253
254
#[ allow( clippy:: too_many_lines) ]
254
- pub fn config ( subcommand : & ConfigSubCommand , parameters : & Option < String > , mounted_path : Option < & String > , as_group : & bool , as_include : & bool ) {
255
+ pub fn config ( subcommand : & ConfigSubCommand , parameters : & Option < String > , mounted_path : Option < & String > , as_group : & bool , as_include : & bool , progress_format : ProgressFormat ) {
255
256
let ( new_parameters, json_string) = match subcommand {
256
257
ConfigSubCommand :: Get { input, file, .. } |
257
258
ConfigSubCommand :: Set { input, file, .. } |
@@ -295,6 +296,8 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, mounte
295
296
}
296
297
} ;
297
298
299
+ configurator. set_progress_format ( progress_format) ;
300
+
298
301
if let ConfigSubCommand :: Set { what_if , .. } = subcommand {
299
302
if * what_if {
300
303
configurator. context . execution_type = ExecutionKind :: WhatIf ;
@@ -382,7 +385,7 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, mounte
382
385
}
383
386
}
384
387
} else {
385
- match validate_config ( configurator. get_config ( ) ) {
388
+ match validate_config ( configurator. get_config ( ) , progress_format ) {
386
389
Ok ( ( ) ) => {
387
390
// valid, so do nothing
388
391
} ,
@@ -450,7 +453,7 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, mounte
450
453
/// # Errors
451
454
///
452
455
/// * `DscError` - The error that occurred.
453
- pub fn validate_config ( config : & Configuration ) -> Result < ( ) , DscError > {
456
+ pub fn validate_config ( config : & Configuration , progress_format : ProgressFormat ) -> Result < ( ) , DscError > {
454
457
// first validate against the config schema
455
458
debug ! ( "{}" , t!( "subcommand.validatingConfiguration" ) ) ;
456
459
let schema = serde_json:: to_value ( get_schema ( DscType :: Configuration ) ) ?;
@@ -476,7 +479,7 @@ pub fn validate_config(config: &Configuration) -> Result<(), DscError> {
476
479
477
480
resource_types. push ( type_name. to_lowercase ( ) . to_string ( ) ) ;
478
481
}
479
- dsc. find_resources ( & resource_types) ;
482
+ dsc. find_resources ( & resource_types, progress_format ) ;
480
483
481
484
for resource_block in resources {
482
485
let Some ( type_name) = resource_block[ "type" ] . as_str ( ) else {
@@ -527,7 +530,7 @@ pub fn validate_config(config: &Configuration) -> Result<(), DscError> {
527
530
}
528
531
529
532
#[ allow( clippy:: too_many_lines) ]
530
- pub fn resource ( subcommand : & ResourceSubCommand ) {
533
+ pub fn resource ( subcommand : & ResourceSubCommand , progress_format : ProgressFormat ) {
531
534
let mut dsc = match DscManager :: new ( ) {
532
535
Ok ( dsc) => dsc,
533
536
Err ( err) => {
@@ -538,43 +541,43 @@ pub fn resource(subcommand: &ResourceSubCommand) {
538
541
539
542
match subcommand {
540
543
ResourceSubCommand :: List { resource_name, adapter_name, description, tags, output_format } => {
541
- list_resources ( & mut dsc, resource_name. as_ref ( ) , adapter_name. as_ref ( ) , description. as_ref ( ) , tags. as_ref ( ) , output_format. as_ref ( ) ) ;
544
+ list_resources ( & mut dsc, resource_name. as_ref ( ) , adapter_name. as_ref ( ) , description. as_ref ( ) , tags. as_ref ( ) , output_format. as_ref ( ) , progress_format ) ;
542
545
} ,
543
546
ResourceSubCommand :: Schema { resource , output_format } => {
544
- dsc. find_resources ( & [ resource. to_string ( ) ] ) ;
547
+ dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format ) ;
545
548
resource_command:: schema ( & dsc, resource, output_format. as_ref ( ) ) ;
546
549
} ,
547
550
ResourceSubCommand :: Export { resource, output_format } => {
548
- dsc. find_resources ( & [ resource. to_string ( ) ] ) ;
551
+ dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format ) ;
549
552
resource_command:: export ( & mut dsc, resource, output_format. as_ref ( ) ) ;
550
553
} ,
551
554
ResourceSubCommand :: Get { resource, input, file : path, all, output_format } => {
552
- dsc. find_resources ( & [ resource. to_string ( ) ] ) ;
555
+ dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format ) ;
553
556
if * all { resource_command:: get_all ( & dsc, resource, output_format. as_ref ( ) ) ; }
554
557
else {
555
558
let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
556
559
resource_command:: get ( & dsc, resource, parsed_input, output_format. as_ref ( ) ) ;
557
560
}
558
561
} ,
559
562
ResourceSubCommand :: Set { resource, input, file : path, output_format } => {
560
- dsc. find_resources ( & [ resource. to_string ( ) ] ) ;
563
+ dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format ) ;
561
564
let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
562
565
resource_command:: set ( & dsc, resource, parsed_input, output_format. as_ref ( ) ) ;
563
566
} ,
564
567
ResourceSubCommand :: Test { resource, input, file : path, output_format } => {
565
- dsc. find_resources ( & [ resource. to_string ( ) ] ) ;
568
+ dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format ) ;
566
569
let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
567
570
resource_command:: test ( & dsc, resource, parsed_input, output_format. as_ref ( ) ) ;
568
571
} ,
569
572
ResourceSubCommand :: Delete { resource, input, file : path } => {
570
- dsc. find_resources ( & [ resource. to_string ( ) ] ) ;
573
+ dsc. find_resources ( & [ resource. to_string ( ) ] , progress_format ) ;
571
574
let parsed_input = get_input ( input. as_ref ( ) , path. as_ref ( ) ) ;
572
575
resource_command:: delete ( & dsc, resource, parsed_input) ;
573
576
} ,
574
577
}
575
578
}
576
579
577
- fn list_resources ( dsc : & mut DscManager , resource_name : Option < & String > , adapter_name : Option < & String > , description : Option < & String > , tags : Option < & Vec < String > > , format : Option < & OutputFormat > ) {
580
+ fn list_resources ( dsc : & mut DscManager , resource_name : Option < & String > , adapter_name : Option < & String > , description : Option < & String > , tags : Option < & Vec < String > > , format : Option < & OutputFormat > , progress_format : ProgressFormat ) {
578
581
let mut write_table = false ;
579
582
let mut table = Table :: new ( & [
580
583
t ! ( "subcommand.tableHeader_type" ) . to_string ( ) . as_ref ( ) ,
@@ -588,7 +591,7 @@ fn list_resources(dsc: &mut DscManager, resource_name: Option<&String>, adapter_
588
591
// write as table if format is not specified and interactive
589
592
write_table = true ;
590
593
}
591
- for resource in dsc. list_available_resources ( resource_name. unwrap_or ( & String :: from ( "*" ) ) , adapter_name. unwrap_or ( & String :: new ( ) ) ) {
594
+ for resource in dsc. list_available_resources ( resource_name. unwrap_or ( & String :: from ( "*" ) ) , adapter_name. unwrap_or ( & String :: new ( ) ) , progress_format ) {
592
595
let mut capabilities = "--------" . to_string ( ) ;
593
596
let capability_types = [
594
597
( Capability :: Get , "g" ) ,
0 commit comments