@@ -21,21 +21,32 @@ use jaq_all::{jaq_core::{Ctx, Vars, data::JustLut}, jaq_std};
2121struct Cli {
2222 #[ arg( short, long, help = "Cpon indentation string" ) ]
2323 indent : Option < String > ,
24+
2425 #[ arg( short, long, help = "Do not create oneliners in Cpon indented string output" ) ]
2526 no_oneliners : bool ,
27+
2628 #[ arg( long = "ip" , help = "Cpon input" ) ]
2729 cpon_input : bool ,
30+
2831 #[ arg( long = "oc" , help = "ChainPack output" ) ]
2932 chainpack_output : bool ,
33+
3034 /// Expect input data in RPC block transport format, https://silicon-heaven.github.io/shv-doc/rpctransportlayer/stream.html
3135 #[ arg( long) ]
3236 chainpack_rpc_block : bool ,
37+
38+ /// Find this path in the input before processing
39+ #[ arg( long) ]
40+ find_path : Option < String > ,
41+
3342 /// Verbose mode (module, .)
3443 #[ arg( short = 'v' , long = "verbose" ) ]
3544 verbose : Option < String > ,
45+
3646 /// File to process
3747 #[ arg( value_name = "FILE" ) ]
3848 file : Option < PathBuf > ,
49+
3950 /// Run cq with this filter.
4051 #[ cfg( feature = "cq" ) ]
4152 #[ arg( long = "cq" ) ]
@@ -152,6 +163,19 @@ fn main() {
152163 process_chainpack_rpc_block_and_exit ( reader)
153164 }
154165
166+ if let Some ( find_path) = opts. find_path {
167+ let mut rd: Box < dyn Reader + ' _ > = if opts. cpon_input {
168+ Box :: new ( CponReader :: new ( & mut reader) )
169+ } else {
170+ Box :: new ( ChainPackReader :: new ( & mut reader) )
171+ } ;
172+ let path = find_path. split ( '/' ) . collect :: < Vec < _ > > ( ) ;
173+ if let Err ( e) = rd. find_path ( & path) {
174+ eprintln ! ( "Path not found: {e:?}" ) ;
175+ process:: exit ( CODE_READ_ERROR ) ;
176+ }
177+ }
178+
155179 let cpon_output = !opts. chainpack_output ;
156180 let use_in_memory_parser = cpon_output && !opts. no_oneliners ;
157181 #[ cfg( feature = "cq" ) ]
0 commit comments