Skip to content

Commit b000f1d

Browse files
refactor: simplify command pattern matching in CLI handler
1 parent 1238575 commit b000f1d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
123123
}
124124
let rpc_client = RpcClient::new(config.json_rpc_url.clone());
125125

126-
match (sub_command, sub_matches) {
127-
("balance", Some(arg_matches)) => {
126+
match sub_command {
127+
"balance" => {
128128
let address =
129129
pubkey_of(arg_matches, "address").unwrap_or_else(|| config.default_signer.pubkey());
130130
println!(
@@ -596,7 +596,8 @@ Use 'osvm examples --category <name>' to show examples for a specific category."
596596
}
597597
}
598598
}
599-
("rpc", Some(rpc_matches)) => {
599+
"rpc" => {
600+
let rpc_matches = sub_matches;
600601
let (rpc_sub_command, rpc_sub_matches) = rpc_matches.subcommand();
601602
match (rpc_sub_command, rpc_sub_matches) {
602603
("sonic", Some(sonic_matches)) => {
@@ -717,7 +718,7 @@ Use 'osvm examples --category <name>' to show examples for a specific category."
717718
}
718719
}
719720
// Handle SSH deployment (format: osvm user@host --svm svm1,svm2)
720-
(conn_str, _) if conn_str.contains('@') && clap_compat::is_present(matches, "svm") => {
721+
conn_str if conn_str.contains('@') && clap_compat::is_present(matches, "svm") => {
721722
// This is an SSH deployment command
722723
let svm_list = clap_compat::value_of(matches, "svm").unwrap();
723724
let node_type_str = clap_compat::value_of(matches, "node-type").unwrap();
@@ -779,7 +780,7 @@ Use 'osvm examples --category <name>' to show examples for a specific category."
779780
"new_feature_command" => {
780781
println!("Expected output for new feature");
781782
}
782-
(cmd, _) => {
783+
cmd => {
783784
eprintln!("Unknown command: {}", cmd);
784785
exit(1);
785786
}
@@ -816,4 +817,4 @@ mod test {
816817
// Assert that the deserialized data matches the original
817818
assert_eq!(faux, in_faux);
818819
}
819-
}
820+
}

0 commit comments

Comments
 (0)