File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[package ]
22name = " rxing-cli"
3- version = " 0.2.2 "
4- edition = " 2021 "
3+ version = " 0.2.3 "
4+ edition = " 2024 "
55description = " A command line interface for rxing supporting encoding and decoding of multiple barcode formats"
66license =" Apache-2.0"
77repository =" https://github.com/rxing-core/rxing/tree/main/crates/cli"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ use std::{
66
77use clap:: { ArgGroup , Parser , Subcommand } ;
88use rxing:: { BarcodeFormat , MultiFormatWriter , Writer } ;
9+ use serde_json:: de;
910
1011#[ derive( Parser ) ]
1112#[ command( author, version, about, long_about = None ) ]
@@ -432,11 +433,25 @@ fn decode_command(
432433 } ;
433434 match results {
434435 Ok ( result_array) => {
435- println ! ( "Found {} results" , result_array. len( ) ) ;
436+ if !* detailed_results_json {
437+ println ! ( "Found {} results" , result_array. len( ) ) ;
438+ } else {
439+ println ! ( "[" ) ;
440+ }
436441 for ( i, result) in result_array. into_iter ( ) . enumerate ( ) {
442+ let json_prefix = if * detailed_results_json && i > 0 {
443+ ","
444+ } else {
445+ ""
446+ } ;
447+ let prefix = if * detailed_results_json {
448+ json_prefix. to_string ( )
449+ } else {
450+ format ! ( "\n Result {}:" , i)
451+ } ;
437452 println ! (
438- "Result {}: \n {}" ,
439- i ,
453+ "{} \n {}" ,
454+ prefix ,
440455 print_result(
441456 & result,
442457 * detailed_result,
@@ -446,6 +461,9 @@ fn decode_command(
446461 )
447462 ) ;
448463 }
464+ if * detailed_results_json {
465+ println ! ( "]" ) ;
466+ }
449467 ExitCode :: SUCCESS
450468 }
451469 Err ( search_err) => {
You can’t perform that action at this time.
0 commit comments