@@ -86,6 +86,35 @@ pub fn config_test(configurator: Configurator, format: &Option<OutputFormat>)
8686 }
8787}
8888
89+ pub fn config_export ( configurator : Configurator , format : & Option < OutputFormat > )
90+ {
91+ match configurator. invoke_export ( ErrorAction :: Continue , || { /* code */ } ) {
92+ Ok ( result) => {
93+ let json = match serde_json:: to_string ( & result. result ) {
94+ Ok ( json) => json,
95+ Err ( err) => {
96+ eprintln ! ( "JSON Error: {err}" ) ;
97+ exit ( EXIT_JSON_ERROR ) ;
98+ }
99+ } ;
100+ write_output ( & json, format) ;
101+ if result. had_errors {
102+
103+ for msg in result. messages
104+ {
105+ eprintln ! ( "{:?} message {}" , msg. level, msg. message) ;
106+ } ;
107+
108+ exit ( EXIT_DSC_ERROR ) ;
109+ }
110+ } ,
111+ Err ( err) => {
112+ eprintln ! ( "Error: {err}" ) ;
113+ exit ( EXIT_DSC_ERROR ) ;
114+ }
115+ }
116+ }
117+
89118pub fn config ( subcommand : & ConfigSubCommand , format : & Option < OutputFormat > , stdin : & Option < String > ) {
90119 if stdin. is_none ( ) {
91120 eprintln ! ( "Configuration must be piped to STDIN" ) ;
@@ -134,6 +163,9 @@ pub fn config(subcommand: &ConfigSubCommand, format: &Option<OutputFormat>, stdi
134163 } ,
135164 ConfigSubCommand :: Validate => {
136165 validate_config ( & json_string) ;
166+ } ,
167+ ConfigSubCommand :: Export => {
168+ config_export ( configurator, format) ;
137169 }
138170 }
139171}
@@ -353,8 +385,9 @@ pub fn resource(subcommand: &ResourceSubCommand, format: &Option<OutputFormat>,
353385 table. print ( ) ;
354386 }
355387 } ,
356- ResourceSubCommand :: Get { resource, input } => {
357- resource_command:: get ( & mut dsc, resource, input, stdin, format) ;
388+ ResourceSubCommand :: Get { resource, input, all } => {
389+ if * all { resource_command:: get_all ( & mut dsc, resource, input, stdin, format) ; }
390+ else { resource_command:: get ( & mut dsc, resource, input, stdin, format) ; } ;
358391 } ,
359392 ResourceSubCommand :: Set { resource, input } => {
360393 resource_command:: set ( & mut dsc, resource, input, stdin, format) ;
@@ -365,5 +398,8 @@ pub fn resource(subcommand: &ResourceSubCommand, format: &Option<OutputFormat>,
365398 ResourceSubCommand :: Schema { resource } => {
366399 resource_command:: schema ( & mut dsc, resource, format) ;
367400 } ,
401+ ResourceSubCommand :: Export { resource} => {
402+ resource_command:: export ( & mut dsc, resource, format) ;
403+ } ,
368404 }
369405}
0 commit comments