@@ -159,6 +159,7 @@ impl Args {
159159 } ;
160160 Ok ( ser)
161161 }
162+
162163 fn read_toml ( & mut self ) -> Result < Vec < u8 > > {
163164 use toml:: Table ;
164165 let mut buf = String :: new ( ) ;
@@ -180,15 +181,14 @@ impl Args {
180181 let doc_as: serde_json:: Value = doc. try_into ( ) ?;
181182 Ok ( serde_json:: to_vec ( & doc_as) ?)
182183 }
184+
183185 fn read_json ( & mut self ) -> Result < Vec < u8 > > {
184186 let json_value: serde_json:: Value = if let Some ( f) = & self . file {
185187 if !std:: path:: Path :: new ( & f) . exists ( ) {
186188 Self :: try_parse_from ( [ "cmd" , "-h" ] ) ?;
187189 std:: process:: exit ( 2 ) ;
188190 }
189191 let file = std:: fs:: File :: open ( f) ?;
190- // NB: can do everything async (via tokio + tokio_util) except this:
191- // serde only has a sync reader interface, so may as well do all sync.
192192 serde_json:: from_reader ( BufReader :: new ( file) ) ?
193193 } else if !stdin ( ) . is_terminal ( ) && !cfg ! ( test) {
194194 debug ! ( "reading from stdin" ) ;
@@ -197,11 +197,9 @@ impl Args {
197197 Self :: try_parse_from ( [ "cmd" , "-h" ] ) ?;
198198 std:: process:: exit ( 2 ) ;
199199 } ;
200-
201- // TODO: if slurp and json value is an array...
202-
203200 Ok ( serde_json:: to_vec ( & json_value) ?)
204201 }
202+
205203 fn read_input ( & mut self ) -> Result < Vec < u8 > > {
206204 let ser = match self . input {
207205 Input :: Yaml => self . read_yaml ( ) ?,
0 commit comments