File tree Expand file tree Collapse file tree 5 files changed +30
-1
lines changed Expand file tree Collapse file tree 5 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ pub struct CardanoDbDownloadCommand {
46
46
}
47
47
48
48
impl CardanoDbDownloadCommand {
49
+ /// Is JSON output enabled
50
+ pub fn is_json_output_enabled ( & self ) -> bool {
51
+ self . json
52
+ }
53
+
49
54
/// Command execution
50
55
pub async fn execute ( & self , config_builder : ConfigBuilder < DefaultState > ) -> MithrilResult < ( ) > {
51
56
let config = config_builder. add_source ( self . clone ( ) ) . build ( ) ?;
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ pub struct CardanoDbListCommand {
15
15
}
16
16
17
17
impl CardanoDbListCommand {
18
+ /// Is JSON output enabled
19
+ pub fn is_json_output_enabled ( & self ) -> bool {
20
+ self . json
21
+ }
22
+
18
23
/// Main command execution
19
24
pub async fn execute ( & self , config_builder : ConfigBuilder < DefaultState > ) -> MithrilResult < ( ) > {
20
25
let config = config_builder. build ( ) ?;
Original file line number Diff line number Diff line change @@ -87,5 +87,14 @@ pub mod deprecated {
87
87
Self :: Show ( cmd) => cmd. execute ( config_builder) . await ,
88
88
}
89
89
}
90
+
91
+ /// Is JSON output enabled
92
+ pub fn is_json_output_enabled ( & self ) -> bool {
93
+ match self {
94
+ Self :: List ( cmd) => cmd. is_json_output_enabled ( ) ,
95
+ Self :: Download ( cmd) => cmd. is_json_output_enabled ( ) ,
96
+ Self :: Show ( cmd) => cmd. is_json_output_enabled ( ) ,
97
+ }
98
+ }
90
99
}
91
100
}
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ pub struct CardanoDbShowCommand {
24
24
}
25
25
26
26
impl CardanoDbShowCommand {
27
+ /// Is JSON output enabled
28
+ pub fn is_json_output_enabled ( & self ) -> bool {
29
+ self . json
30
+ }
31
+
27
32
/// Cardano DB Show command
28
33
pub async fn execute ( & self , config_builder : ConfigBuilder < DefaultState > ) -> MithrilResult < ( ) > {
29
34
let config = config_builder. build ( ) ?;
Original file line number Diff line number Diff line change @@ -190,7 +190,12 @@ impl ArtifactCommands {
190
190
match self {
191
191
#[ allow( deprecated) ]
192
192
Self :: Snapshot ( cmd) => {
193
- eprintln ! ( "`snapshot` command is deprecated, use `cardano-db` instead" ) ;
193
+ let message = "`snapshot` command is deprecated, use `cardano-db` instead" ;
194
+ if cmd. is_json_output_enabled ( ) {
195
+ eprintln ! ( r#"{{"warning": "{}", "type": "deprecation"}}"# , message) ;
196
+ } else {
197
+ eprintln ! ( "{}" , message) ;
198
+ } ;
194
199
cmd. execute ( config_builder) . await
195
200
}
196
201
Self :: CardanoDb ( cmd) => cmd. execute ( config_builder) . await ,
You can’t perform that action at this time.
0 commit comments