@@ -5,7 +5,7 @@ use crate::args::{ConfigSubCommand, DscType, OutputFormat, ResourceSubCommand};
5
5
use crate :: resolve:: { get_contents, Include } ;
6
6
use crate :: resource_command:: { get_resource, self } ;
7
7
use crate :: tablewriter:: Table ;
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} ;
8
+ use crate :: util:: { DSC_CONFIG_ROOT , EXIT_DSC_ERROR , EXIT_INVALID_ARGS , EXIT_INVALID_INPUT , EXIT_JSON_ERROR , get_schema, write_object , get_input, set_dscconfigroot, validate_json} ;
9
9
use dsc_lib:: {
10
10
configure:: {
11
11
config_doc:: {
@@ -48,7 +48,7 @@ pub fn config_get(configurator: &mut Configurator, format: Option<&OutputFormat>
48
48
exit ( EXIT_JSON_ERROR ) ;
49
49
}
50
50
} ;
51
- write_output ( & json, format) ;
51
+ write_object ( & json, format, false ) ;
52
52
}
53
53
else {
54
54
let json = match serde_json:: to_string ( & result) {
@@ -58,7 +58,7 @@ pub fn config_get(configurator: &mut Configurator, format: Option<&OutputFormat>
58
58
exit ( EXIT_JSON_ERROR ) ;
59
59
}
60
60
} ;
61
- write_output ( & json, format) ;
61
+ write_object ( & json, format, false ) ;
62
62
if result. had_errors {
63
63
exit ( EXIT_DSC_ERROR ) ;
64
64
}
@@ -83,7 +83,7 @@ pub fn config_set(configurator: &mut Configurator, format: Option<&OutputFormat>
83
83
exit ( EXIT_JSON_ERROR ) ;
84
84
}
85
85
} ;
86
- write_output ( & json, format) ;
86
+ write_object ( & json, format, false ) ;
87
87
}
88
88
else {
89
89
let json = match serde_json:: to_string ( & result) {
@@ -93,7 +93,7 @@ pub fn config_set(configurator: &mut Configurator, format: Option<&OutputFormat>
93
93
exit ( EXIT_JSON_ERROR ) ;
94
94
}
95
95
} ;
96
- write_output ( & json, format) ;
96
+ write_object ( & json, format, false ) ;
97
97
if result. had_errors {
98
98
exit ( EXIT_DSC_ERROR ) ;
99
99
}
@@ -169,7 +169,7 @@ pub fn config_test(configurator: &mut Configurator, format: Option<&OutputFormat
169
169
}
170
170
}
171
171
} ;
172
- write_output ( & json, format) ;
172
+ write_object ( & json, format, false ) ;
173
173
}
174
174
else {
175
175
let json = match serde_json:: to_string ( & result) {
@@ -179,7 +179,7 @@ pub fn config_test(configurator: &mut Configurator, format: Option<&OutputFormat
179
179
exit ( EXIT_JSON_ERROR ) ;
180
180
}
181
181
} ;
182
- write_output ( & json, format) ;
182
+ write_object ( & json, format, false ) ;
183
183
if result. had_errors {
184
184
exit ( EXIT_DSC_ERROR ) ;
185
185
}
@@ -203,7 +203,7 @@ pub fn config_export(configurator: &mut Configurator, format: Option<&OutputForm
203
203
exit ( EXIT_JSON_ERROR ) ;
204
204
}
205
205
} ;
206
- write_output ( & json, format) ;
206
+ write_object ( & json, format, false ) ;
207
207
if result. had_errors {
208
208
209
209
for msg in result. messages
@@ -401,7 +401,7 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, mounte
401
401
exit ( EXIT_JSON_ERROR ) ;
402
402
} ;
403
403
404
- write_output ( & json, output_format. as_ref ( ) ) ;
404
+ write_object ( & json, output_format. as_ref ( ) , false ) ;
405
405
} ,
406
406
ConfigSubCommand :: Export { output_format, .. } => {
407
407
config_export ( & mut configurator, output_format. as_ref ( ) ) ;
@@ -435,7 +435,7 @@ pub fn config(subcommand: &ConfigSubCommand, parameters: &Option<String>, mounte
435
435
exit ( EXIT_JSON_ERROR ) ;
436
436
}
437
437
} ;
438
- write_output ( & json_string, output_format. as_ref ( ) ) ;
438
+ write_object ( & json_string, output_format. as_ref ( ) , false ) ;
439
439
} ,
440
440
}
441
441
}
@@ -591,6 +591,7 @@ fn list_resources(dsc: &mut DscManager, resource_name: Option<&String>, adapter_
591
591
// write as table if format is not specified and interactive
592
592
write_table = true ;
593
593
}
594
+ let mut first = true ;
594
595
for resource in dsc. list_available_resources ( resource_name. unwrap_or ( & String :: from ( "*" ) ) , adapter_name. unwrap_or ( & String :: new ( ) ) , progress_format) {
595
596
let mut capabilities = "--------" . to_string ( ) ;
596
597
let capability_types = [
@@ -667,7 +668,8 @@ fn list_resources(dsc: &mut DscManager, resource_name: Option<&String>, adapter_
667
668
exit ( EXIT_JSON_ERROR ) ;
668
669
}
669
670
} ;
670
- write_output ( & json, format) ;
671
+ write_object ( & json, format, !first) ;
672
+ first = false ;
671
673
// insert newline separating instances if writing to console
672
674
if io:: stdout ( ) . is_terminal ( ) { println ! ( ) ; }
673
675
}
0 commit comments