This repository was archived by the owner on Feb 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,21 @@ async fn run() -> std::result::Result<(), ClientError> {
144144 }
145145 . await
146146 . map_err ( map_storage_error) ?;
147- tokio:: io:: stdout ( ) . write_all ( & toml:: to_vec ( & inv) ?) . await ?;
147+
148+ match info_opts. output {
149+ Some ( format) if & format == "toml" => {
150+ tokio:: io:: stdout ( ) . write_all ( & toml:: to_vec ( & inv) ?) . await ?
151+ }
152+ Some ( format) if & format == "json" => {
153+ tokio:: io:: stdout ( )
154+ . write_all ( & serde_json:: to_vec_pretty ( & inv) ?)
155+ . await ?
156+ }
157+ Some ( format) => {
158+ return Err ( ClientError :: Other ( format ! ( "Unknown format: {}" , format) ) )
159+ }
160+ None => tokio:: io:: stdout ( ) . write_all ( & toml:: to_vec ( & inv) ?) . await ?,
161+ }
148162 }
149163 SubCommand :: GetInvoice ( gi_opts) => {
150164 let inv = match gi_opts. yanked {
Original file line number Diff line number Diff line change @@ -136,6 +136,13 @@ pub struct Info {
136136 about = "Whether or not to fetch a yanked bindle. If you attempt to fetch a yanked bindle without this set, it will error"
137137 ) ]
138138 pub yanked : bool ,
139+ #[ clap(
140+ short = 'f' ,
141+ long = "output-format" ,
142+ about = "choose an output format" ,
143+ possible_values = & [ "json" , "toml" ] ,
144+ ) ]
145+ pub output : Option < String > ,
139146}
140147
141148#[ derive( Clap ) ]
You can’t perform that action at this time.
0 commit comments