File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed
Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -54,21 +54,15 @@ pub struct Cli {
5454/// as long as it has fields with `#[clap(skip)]`.
5555pub fn parse_cli ( ) -> Cli {
5656 let mut os_args: Vec < _ > = std:: env:: args_os ( ) . collect ( ) ;
57- let Some ( arg1) = os_args. get ( 1 ) else {
58- // No subcommand provided, let clap handle showing the help message.
59- return Cli :: parse_from ( os_args) ;
60- } ;
57+ let arg1 = os_args. get ( 1 ) . and_then ( |arg1| arg1. to_str ( ) ) ;
6158
6259 // If a valid subcommand was provided, run it. Otherwise, default to the
6360 // `node` subcommand and let clap handle any errors.
64- let is_valid_command = if let Some ( arg1) = arg1. as_os_str ( ) . to_str ( ) {
65- CommandKind :: from_str ( arg1) . is_ok ( )
66- } else {
67- false
68- } ;
69-
70- if !is_valid_command {
71- os_args. insert ( 1 , "node" . into ( ) ) ;
61+ match arg1 {
62+ Some ( arg1) if CommandKind :: from_str ( arg1) . is_ok ( ) => { }
63+ _ => {
64+ os_args. insert ( 1 , "node" . into ( ) ) ;
65+ }
7266 }
7367
7468 Cli :: parse_from ( os_args)
You can’t perform that action at this time.
0 commit comments