@@ -65,6 +65,9 @@ pub struct Options {
6565 /// Input is a series of YAML documents.
6666 #[ structopt( short = "y" , long = "input-yaml" ) ]
6767 pub flag_input_yaml : bool ,
68+ /// Input is formatted as SMILE
69+ #[ structopt( short = "s" , long = "input-smile" ) ]
70+ pub flag_input_smile : bool ,
6871
6972 #[ structopt( short = "A" , long = "output-avro" ) ]
7073 pub flag_output_avro : Option < String > ,
@@ -84,6 +87,8 @@ pub struct Options {
8487 pub flag_output_toml : bool ,
8588 #[ structopt( short = "Y" , long = "output-yaml" ) ]
8689 pub flag_output_yaml : bool ,
90+ #[ structopt( short = "S" , long = "output-smile" ) ]
91+ pub flag_output_smile : bool ,
8792
8893 #[ structopt( short = "l" , long = "log" ) ]
8994 pub flag_log : Option < String > ,
@@ -179,6 +184,9 @@ fn run(args: &Options) -> rq::error::Result<()> {
179184 } else if args. flag_input_yaml {
180185 let source = rq:: value:: yaml:: source ( & mut input) ;
181186 run_source ( args, source)
187+ } else if args. flag_input_smile {
188+ let source = rq:: value:: smile:: source ( & mut input) ?;
189+ run_source ( args, source)
182190 } else if args. flag_input_raw {
183191 let source = rq:: value:: raw:: source ( & mut input) ;
184192 run_source ( args, source)
@@ -277,6 +285,9 @@ where
277285 rq:: value:: yaml:: sink,
278286 rq:: value:: yaml:: sink
279287 )
288+ } else if args. flag_output_smile {
289+ let sink = rq:: value:: smile:: sink ( & mut output) ?;
290+ run_source_sink ( source, sink)
280291 } else if args. flag_output_raw {
281292 let sink = rq:: value:: raw:: sink ( & mut output) ;
282293 run_source_sink ( source, sink)
@@ -593,6 +604,30 @@ mod test {
593604 assert ! ( a. flag_output_cbor) ;
594605 }
595606
607+ #[ test]
608+ fn test_docopt_input_smile ( ) {
609+ let a = parse_args ( & [ "rq" , "-s" ] ) ;
610+ assert ! ( a. flag_input_smile) ;
611+ }
612+
613+ #[ test]
614+ fn test_docopt_input_smile_long ( ) {
615+ let a = parse_args ( & [ "rq" , "--input-smile" ] ) ;
616+ assert ! ( a. flag_input_smile) ;
617+ }
618+
619+ #[ test]
620+ fn test_docopt_output_smile ( ) {
621+ let a = parse_args ( & [ "rq" , "-S" ] ) ;
622+ assert ! ( a. flag_output_smile) ;
623+ }
624+
625+ #[ test]
626+ fn test_docopt_output_smile_long ( ) {
627+ let a = parse_args ( & [ "rq" , "--output-smile" ] ) ;
628+ assert ! ( a. flag_output_smile) ;
629+ }
630+
596631 #[ test]
597632 fn test_docopt_input_protobuf ( ) {
598633 let a = parse_args ( & [ "rq" , "-p" , ".foo.Bar" ] ) ;
0 commit comments