-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing subsubcommand matches #766
Comments
It's not the typical way to do it, but you can change your code to work below: let matches = App::from_yaml(yml).get_matches();
// subcommand_matches returns an option
let subcommand_matches = matches.subcommand_matches(matches.subcommand_name().unwrap()).unwrap();
let subsubcommand_matches = subcommand_matches.subcommand_matches(matches.subcommand_name().unwrap()).unwrap(); The more common way to do this is: match matches.subcommand() {
("foo", Some(foo_matches)) => {
// Handle the myprog foo subcommand
},
("bar", Some(bar_matches)) => {
// Handle myprog bar subcommand
match bar_matches.subcommand() {
("baz", Some(baz_matches)) => {
// handle myprog bar baz subcommand
},
_ => unreachabe!()
}
},
_ => unreachabe!()
} etc. |
Great, thank you once again and apologies for a newbie question. Do you think it's worth adding such example to |
For sure! We can always use more examples. I'll add it on my next doc sweep unless someone else beats me to it. |
docs(Examples): adds subcommand examples Closes #766 cc @omtcyfz
docs(Examples): adds subcommand examples Closes #766 cc @omtcyfz
From what I have seen it is not clear how a sub-subcommand matches should be accessed.
What I expect to see is something like
However, I get
With
Am I just missing something or is such kind of subsubcommand extraction not supported?
The text was updated successfully, but these errors were encountered: