-
Notifications
You must be signed in to change notification settings - Fork 152
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
Adding subcommands to a pre-existing structopt #327
Comments
I would go for Also, I would like it to be a part of |
Can't we do this kind of thing with #314 and reparsing the Vec into your extended opt using |
Actually this ticket seems totally related to #130 |
That's not the asked syntax, but it might resolve the needed feature. |
I'm afraid it won't because I can't just import an instantiated |
Not really. What he's asking for is "flatten subcommands in the same manner we're flattening structs", he's not asking to "accept every possible subcommand". |
*she But yes this is very different |
@cecton sorry, I don't really look at avatars... |
The feature needed is "allow to have an Enum for extended subcommand". While maybe less ergonomic, it would be possible with something like that: let opt = BaseOpt::from_args();
let extended = match &opt.cmd {
Some(Extended(v)) => Some(ExtendedOpt::from_iter(v)),
_ => None,
}; |
@CreepySkeleton I think that's the missing feature: we would like to be able to extend an enum of subcommands from another crate.
To be clear it doesn't have to use flatten in this fashion. But it would be nice if there would be a way to add a subcommand to an existing list of subcommands. Unfortunately Rust won't allow adding variants in the enum, the usual way to deal with this is this: https://stackoverflow.com/questions/25214064/can-i-extend-an-enum-with-additional-values#25214677 so there should be a way to tell structopt that the subcommands in the variant (
BaseCli::Command1
) should be at the same level than the subcommands in the parent enum (ExtendedCli::Command2
).This issue relates to #20 but is different as this is importing a StructOpt from a different crate.
This issue relates to #307
Code
Expected Result
Actual Result
The text was updated successfully, but these errors were encountered: