Allow subcommand flattening
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
There is already an issue open for struct flattening. This one is specifically for subcommand flattenin.
Here is use-case example (using proc-macro from second comment):
```rust
#[derive(FromArgs, PartialEq, Debug)]
/// Top-level command.
struct TopLevel {
#[argh(subcommand)]
nested: MySubCommandEnum,
}
#[derive(PartialEq, Debug, FlattenSubcommand)]
enum MySubCommandEnum {
Global(MySubCommandEnumGlobal),
Sys(MySubCommandEnumSys),
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
enum MySubCommandEnumGlobal {
One(SubCommandOne),
Two(SubCommandTwo),
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
enum MySubCommandEnumSys {
Three(SubCommandThree),
Four(SubCommandFour),
}
#[derive(FromArgs, PartialEq, Debug)]
/// First subcommand.
#[argh(subcommand, name = "one")]
struct SubCommandOne {}
#[derive(FromArgs, PartialEq, Debug)]
/// Second subcommand.
#[argh(subcommand, name = "two")]
struct SubCommandTwo {
#[argh(option)]
/// x
x: usize,
}
#[derive(FromArgs, PartialEq, Debug)]
/// Third subcommand.
#[argh(subcommand, name = "three")]
struct SubCommandThree {}
#[derive(FromArgs, PartialEq, Debug)]
/// Fourth subcommand.
#[argh(subcommand, name = "four")]
struct SubCommandFour {}
fn main() {
let up: TopLevel = argh::from_env();
println!("{:?}", up);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.