@@ -9,22 +9,46 @@ struct Token {
99
1010pub fn suggest ( command : & str ) -> Option < String > {
1111 let command = command. trim ( ) ;
12- if command. is_empty ( )
13- || starts_with_rtk ( command) && preferred_rtk_command ( command)
14- || is_preferred_pwsh_wrapper ( command)
15- || is_preferred_bash_wrapper ( command)
12+ if command. is_empty ( ) {
13+ return None ;
14+ }
15+
16+ invalid_rtk_read_redirect ( command) . or_else ( || {
17+ if starts_with_rtk ( command) && preferred_rtk_command ( command)
18+ || is_preferred_pwsh_wrapper ( command)
19+ || is_preferred_bash_wrapper ( command)
20+ {
21+ return None ;
22+ }
23+
24+ direct_powershell_redirect ( command)
25+ . or_else ( || powershell_redirect ( command) )
26+ . or_else ( || env_redirect ( command) )
27+ . or_else ( || bash_redirect ( command) )
28+ . or_else ( || posix_redirect ( command) )
29+ . or_else ( || rg_redirect ( command) )
30+ . or_else ( || safe_external_rtk_rewrite ( command) )
31+ . or_else ( || local_rtk_miss_fallback ( command) )
32+ } )
33+ }
34+
35+ fn invalid_rtk_read_redirect ( command : & str ) -> Option < String > {
36+ let tokens = tokenize ( command) ;
37+ if command_name ( & tokens. first ( ) ?. text ) != "rtk" || command_name ( & tokens. get ( 1 ) ?. text ) != "read"
1638 {
1739 return None ;
1840 }
1941
20- direct_powershell_redirect ( command)
21- . or_else ( || powershell_redirect ( command) )
22- . or_else ( || env_redirect ( command) )
23- . or_else ( || bash_redirect ( command) )
24- . or_else ( || posix_redirect ( command) )
25- . or_else ( || rg_redirect ( command) )
26- . or_else ( || safe_external_rtk_rewrite ( command) )
27- . or_else ( || local_rtk_miss_fallback ( command) )
42+ tokens
43+ . iter ( )
44+ . skip ( 2 )
45+ . any ( |token| {
46+ matches ! ( token. text. as_str( ) , "--line" | "--lines" | "--range" )
47+ || token. text . starts_with ( "--line=" )
48+ || token. text . starts_with ( "--lines=" )
49+ || token. text . starts_with ( "--range=" )
50+ } )
51+ . then ( || "rtk read --help" . to_string ( ) )
2852}
2953
3054fn preferred_rtk_command ( command : & str ) -> bool {
0 commit comments