You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here in we have 2 sub commands for a base command.
in main.rs
let base = argh::from_env()
After that I want to filter out he nested command and use one appropriately.
let sub_command = tt.nested;
println!("{:?}", sub_command);
match sub_command {
MySubCommandEnum::Pub => {
println!("We have to do Publish");
},
MySubCommandEnum::Sub => {
println!("We have to subs");
},
}
When I try to do something like this, I get following error expected unit struct, unit variant or constant, found tuple variant MySubCommandEnum::Pubdid you meanMySubCommandEnum::Pub`
What am I missing? Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hi! This is actually unrelated to argh, it's related to how you use enums with match statements with Rust. You need to write something like:
match sub_command {
MySubCommandEnum::Pub(config) => { // now you can access PublishConfig
println!("We have to do Publish");
},
MySubCommandEnum::Sub(_) => { // if you want to ignore the value use a type hole
println!("We have to subs");
},
}
Here in we have 2 sub commands for a base command.
in
main.rs
After that I want to filter out he nested command and use one appropriately.
When I try to do something like this, I get following error
expected unit struct, unit variant or constant, found tuple variant
MySubCommandEnum::Pubdid you mean
MySubCommandEnum::Pub`What am I missing? Thanks in advance.
The text was updated successfully, but these errors were encountered: