File tree 5 files changed +27
-3
lines changed
5 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use crate::error::CliError;
13
13
pub struct ExportOpt {
14
14
profile_name : Option < String > ,
15
15
#[ arg(
16
- default_value_t = OutputType :: json ,
16
+ default_value_t = OutputType :: toml ,
17
17
short = 'O' ,
18
18
long = "output" ,
19
19
value_name = "type" ,
@@ -27,8 +27,8 @@ impl ExportOpt {
27
27
pub fn process < O : Terminal > ( self , out : Arc < O > ) -> Result < ( ) > {
28
28
let output_format = match self . output_format {
29
29
OutputType :: table => {
30
- eprintln ! ( "Table format is not supported, using JSON instead" ) ;
31
- OutputType :: json
30
+ eprintln ! ( "Table format is not supported, using TOML instead" ) ;
31
+ OutputType :: toml
32
32
}
33
33
_ => self . output_format ,
34
34
} ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ serde_yaml = { workspace = true }
26
26
semver = { workspace = true , features = [" serde" ] }
27
27
thiserror = { workspace = true }
28
28
tracing = { workspace = true }
29
+ toml = { workspace = true , features = [" display" ] }
29
30
30
31
fluvio = { workspace = true , optional = true }
31
32
fluvio-package-index = { workspace = true }
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ mod error {
40
40
41
41
use serde_json:: Error as SerdeJsonError ;
42
42
use serde_yaml:: Error as SerdeYamlError ;
43
+ use toml:: ser:: Error as SerdeTomlError ;
43
44
44
45
#[ derive( thiserror:: Error , Debug ) ]
45
46
pub enum OutputError {
@@ -53,6 +54,11 @@ mod error {
53
54
#[ from]
54
55
source : SerdeYamlError ,
55
56
} ,
57
+ #[ error( "Fluvio client error" ) ]
58
+ SerdeTomlError {
59
+ #[ from]
60
+ source : SerdeTomlError ,
61
+ } ,
56
62
}
57
63
}
58
64
@@ -94,6 +100,7 @@ mod output {
94
100
table,
95
101
yaml,
96
102
json,
103
+ toml,
97
104
}
98
105
99
106
/// OutputType defaults to table formatting
Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ use super::OutputError;
13
13
pub enum SerializeType {
14
14
yaml,
15
15
json,
16
+ toml,
16
17
}
17
18
18
19
impl From < OutputType > for SerializeType {
19
20
fn from ( output : OutputType ) -> Self {
20
21
match output {
21
22
OutputType :: yaml => SerializeType :: yaml,
22
23
OutputType :: json => SerializeType :: json,
24
+ OutputType :: toml => SerializeType :: toml,
23
25
_ => panic ! ( "should never happen" ) ,
24
26
}
25
27
}
42
44
match output_type {
43
45
SerializeType :: yaml => self . to_yaml ( value) ,
44
46
SerializeType :: json => self . to_json ( value) ,
47
+ SerializeType :: toml => self . to_toml ( value) ,
45
48
}
46
49
}
47
50
68
71
69
72
Ok ( ( ) )
70
73
}
74
+
75
+ /// convert to toml format and print to terminal
76
+ fn to_toml < S > ( & self , value : & S ) -> Result < ( ) , OutputError >
77
+ where
78
+ S : Serialize ,
79
+ {
80
+ let serialized = toml:: to_string ( value) ?;
81
+
82
+ self . 0 . println ( & serialized) ;
83
+
84
+ Ok ( ( ) )
85
+ }
71
86
}
You can’t perform that action at this time.
0 commit comments