@@ -54,7 +54,7 @@ pub fn invoke_get(resource: &ResourceManifest, cwd: &str, filter: &str) -> Resul
5454
5555    let  mut  env:  Option < HashMap < String ,  String > >  = None ; 
5656    let  mut  input_filter:  Option < & str >  = None ; 
57-     let  mut   args:   Option < Vec < String > >  =  None ; 
57+     let  args =  process_args ( & resource . get . args ,  filter ) ; 
5858    if  !filter. is_empty ( )  { 
5959        verify_json ( resource,  cwd,  filter) ?; 
6060
@@ -65,9 +65,6 @@ pub fn invoke_get(resource: &ResourceManifest, cwd: &str, filter: &str) -> Resul
6565            InputKind :: Stdin  => { 
6666                input_filter = Some ( filter) ; 
6767            } , 
68-             InputKind :: Arg  => { 
69-                 args = process_args ( & resource. get . args ,  filter) ; 
70-             } , 
7168        } 
7269    } 
7370
@@ -146,17 +143,14 @@ pub fn invoke_set(resource: &ResourceManifest, cwd: &str, desired: &str, skip_te
146143
147144    let  mut  get_env:  Option < HashMap < String ,  String > >  = None ; 
148145    let  mut  get_input:  Option < & str >  = None ; 
149-     let  mut   args:   Option < Vec < String > >  =  None ; 
146+     let  args =  process_args ( & resource . get . args ,  desired ) ; 
150147    match  & resource. get . input  { 
151148        Some ( InputKind :: Env )  => { 
152149            get_env = Some ( json_to_hashmap ( desired) ?) ; 
153150        } , 
154151        Some ( InputKind :: Stdin )  => { 
155152            get_input = Some ( desired) ; 
156153        } , 
157-         Some ( InputKind :: Arg )  => { 
158-             args = process_args ( & resource. get . args ,  desired) ; 
159-         } , 
160154        None  => { 
161155            // leave input as none 
162156        } , 
@@ -183,16 +177,16 @@ pub fn invoke_set(resource: &ResourceManifest, cwd: &str, desired: &str, skip_te
183177
184178    let  mut  env:  Option < HashMap < String ,  String > >  = None ; 
185179    let  mut  input_desired:  Option < & str >  = None ; 
186-     let  mut   args:   Option < Vec < String > >  =  None ; 
180+     let  args =  process_args ( & set . args ,  desired ) ; 
187181    match  & set. input  { 
188-         InputKind :: Env  => { 
182+         Some ( InputKind :: Env )  => { 
189183            env = Some ( json_to_hashmap ( desired) ?) ; 
190184        } , 
191-         InputKind :: Stdin  => { 
185+         Some ( InputKind :: Stdin )  => { 
192186            input_desired = Some ( desired) ; 
193187        } , 
194-         InputKind :: Arg  => { 
195-             args =  process_args ( & set . args ,  desired ) ; 
188+         None  => { 
189+             // leave input as none 
196190        } , 
197191    } 
198192
@@ -289,16 +283,16 @@ pub fn invoke_test(resource: &ResourceManifest, cwd: &str, expected: &str) -> Re
289283
290284    let  mut  env:  Option < HashMap < String ,  String > >  = None ; 
291285    let  mut  input_expected:  Option < & str >  = None ; 
292-     let  mut   args:   Option < Vec < String > >  =  None ; 
286+     let  args =  process_args ( & test . args ,  expected ) ; 
293287    match  & test. input  { 
294-         InputKind :: Env  => { 
288+         Some ( InputKind :: Env )  => { 
295289           env = Some ( json_to_hashmap ( expected) ?) ; 
296290        } , 
297-         InputKind :: Stdin  => { 
291+         Some ( InputKind :: Stdin )  => { 
298292            input_expected = Some ( expected) ; 
299293        } , 
300-         InputKind :: Arg  => { 
301-             args =  process_args ( & test . args ,  expected ) ; 
294+         None  => { 
295+             // leave input as none 
302296        } , 
303297    } 
304298
@@ -391,19 +385,20 @@ pub fn invoke_delete(resource: &ResourceManifest, cwd: &str, filter: &str) -> Re
391385        return  Err ( DscError :: NotImplemented ( "delete" . to_string ( ) ) ) ; 
392386    } ; 
393387
388+     verify_json ( resource,  cwd,  filter) ?; 
389+ 
394390    let  mut  env:  Option < HashMap < String ,  String > >  = None ; 
395391    let  mut  input_filter:  Option < & str >  = None ; 
396-     let  mut  args:  Option < Vec < String > >  = None ; 
397-     verify_json ( resource,  cwd,  filter) ?; 
392+     let  args = process_args ( & delete. args ,  filter) ; 
398393    match  & delete. input  { 
399-         InputKind :: Env  => { 
394+         Some ( InputKind :: Env )  => { 
400395            env = Some ( json_to_hashmap ( filter) ?) ; 
401396        } , 
402-         InputKind :: Stdin  => { 
397+         Some ( InputKind :: Stdin )  => { 
403398            input_filter = Some ( filter) ; 
404399        } , 
405-         InputKind :: Arg  => { 
406-             args =  process_args ( & delete . args ,  filter ) ; 
400+         None  => { 
401+             // leave input as none 
407402        } , 
408403    } 
409404
@@ -441,16 +436,16 @@ pub fn invoke_validate(resource: &ResourceManifest, cwd: &str, config: &str) ->
441436
442437    let  mut  env:  Option < HashMap < String ,  String > >  = None ; 
443438    let  mut  input_config:  Option < & str >  = None ; 
444-     let  mut   args:   Option < Vec < String > >  =  None ; 
439+     let  args =  process_args ( & validate . args ,  config ) ; 
445440    match  & validate. input  { 
446-         InputKind :: Env  => { 
441+         Some ( InputKind :: Env )  => { 
447442            env = Some ( json_to_hashmap ( config) ?) ; 
448443        } , 
449-         InputKind :: Stdin  => { 
444+         Some ( InputKind :: Stdin )  => { 
450445            input_config = Some ( config) ; 
451446        } , 
452-         InputKind :: Arg  => { 
453-             args =  process_args ( & validate . args ,  config ) ; 
447+         None  => { 
448+             // leave input as none 
454449        } , 
455450    } 
456451
@@ -526,24 +521,29 @@ pub fn invoke_export(resource: &ResourceManifest, cwd: &str, input: Option<&str>
526521        return  Err ( DscError :: Operation ( format ! ( "Export is not supported by resource {}" ,  & resource. resource_type) ) ) 
527522    } ; 
528523
524+ 
529525    let  mut  env:  Option < HashMap < String ,  String > >  = None ; 
530526    let  mut  export_input:  Option < & str >  = None ; 
531-     let  mut   args:  Option < Vec < String > >  =  None ; 
527+     let  args:  Option < Vec < String > > ; 
532528    if  let  Some ( input)  = input { 
533-         match   & export . input  { 
534-             Some ( InputKind :: Env )  =>  { 
535-                 env =  Some ( json_to_hashmap ( input) ? ) ; 
536-             } , 
537-             Some ( InputKind :: Stdin )  =>  { 
538-                 export_input =  Some ( input ) ; 
539-             } , 
540-             Some ( InputKind :: Arg )  =>  { 
541-                 args =  process_args ( & export . args ,  input ) ; 
542-             } , 
543-             None  =>  { 
544-                 // leave input as none 
545-             } , 
529+         if  ! input. is_empty ( )  { 
530+             verify_json ( resource ,  cwd ,  input ) ? ; 
531+             match   & export . input   { 
532+                  Some ( InputKind :: Env )  =>  { 
533+                     env =  Some ( json_to_hashmap ( input ) ? ) ; 
534+                 } , 
535+                  Some ( InputKind :: Stdin )  =>  { 
536+                     export_input =  Some ( input ) ; 
537+                 } , 
538+                  None  =>  { 
539+                      // leave input as none 
540+                 } , 
541+             } 
546542        } 
543+ 
544+         args = process_args ( & export. args ,  input) ; 
545+     }  else  { 
546+         args = process_args ( & export. args ,  "" ) ; 
547547    } 
548548
549549    let  ( exit_code,  stdout,  stderr)  = invoke_command ( & export. executable ,  args,  export_input,  Some ( cwd) ,  env) ?; 
@@ -657,7 +657,7 @@ fn process_args(args: &Option<Vec<ArgKind>>, value: &str) -> Option<Vec<String>>
657657                processed_args. push ( s. clone ( ) ) ; 
658658            } , 
659659            ArgKind :: Json  {  json_input_arg,  mandatory }  => { 
660-                 if  value. is_empty ( )  && * mandatory = = Some ( true )  { 
660+                 if  value. is_empty ( )  && * mandatory ! = Some ( true )  { 
661661                    continue ; 
662662                } 
663663
0 commit comments