@@ -21,33 +21,43 @@ use tracing::*;
21
21
22
22
#[ derive( clap:: Parser ) ]
23
23
struct App {
24
- #[ clap ( long, short, arg_enum , default_value_t) ]
24
+ #[ arg ( long, short, default_value_t = OutputMode :: Pretty ) ]
25
25
output : OutputMode ,
26
- #[ clap ( long, short) ]
26
+ #[ arg ( long, short) ]
27
27
file : Option < std:: path:: PathBuf > ,
28
- #[ clap ( long, short = 'l' ) ]
28
+ #[ arg ( long, short = 'l' ) ]
29
29
selector : Option < String > ,
30
- #[ clap ( long, short) ]
30
+ #[ arg ( long, short) ]
31
31
namespace : Option < String > ,
32
- #[ clap ( long, short = 'A' ) ]
32
+ #[ arg ( long, short = 'A' ) ]
33
33
all : bool ,
34
- #[ clap( arg_enum) ]
35
34
verb : Verb ,
36
35
resource : Option < String > ,
37
36
name : Option < String > ,
38
37
}
39
38
40
- #[ derive( clap :: ArgEnum , Clone , PartialEq , Eq ) ]
39
+ #[ derive( Clone , PartialEq , Eq , clap :: ValueEnum ) ]
41
40
enum OutputMode {
42
41
Pretty ,
43
42
Yaml ,
44
43
}
45
- impl Default for OutputMode {
46
- fn default ( ) -> Self {
47
- Self :: Pretty
44
+
45
+ impl OutputMode {
46
+ fn as_str ( & self ) -> & ' static str {
47
+ match self {
48
+ Self :: Pretty => "pretty" ,
49
+ Self :: Yaml => "yaml" ,
50
+ }
51
+ }
52
+ }
53
+
54
+ impl std:: fmt:: Display for OutputMode {
55
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
56
+ f. pad ( self . as_str ( ) )
48
57
}
49
58
}
50
- #[ derive( clap:: ArgEnum , Clone , PartialEq , Eq , Debug ) ]
59
+
60
+ #[ derive( Clone , PartialEq , Eq , Debug , clap:: ValueEnum ) ]
51
61
enum Verb {
52
62
Get ,
53
63
Delete ,
0 commit comments