Skip to content

Commit 97f268c

Browse files
authored
Merge pull request #3283 from eqlabs/sistemd/fix-default-subcommand
fix(cli): always make `node` the default subcommand
2 parents 1f9c2b4 + 361b1ea commit 97f268c

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

crates/pathfinder/src/config.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,15 @@ pub struct Cli {
5454
/// as long as it has fields with `#[clap(skip)]`.
5555
pub 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)

0 commit comments

Comments
 (0)