TeXitoi/structopt

Possible to skip an enum variant for a subcommand?

chipsenkbeil opened this issue · 2 comments

Is there any way to ignore or skip a variant in an enum being used as a subcommand?

#[derive(StructOpt)]
struct Opt {
    #[structopt(subcommand)]
    subcommand: Subcommand,
}

#[derive(StructOpt)]
enum Subcommand {
    One { arg: u8 },
    Two ( arg: u8 },

    // Don't make this available as a subcommand
    #[structopt(skip)]
    Three { arg: u8 },
}

I've got a large enum that is both used as subcommands for a CLI interface as well as the data for network calls by serializing as JSON using serde_json. This has worked great and cut down on the need to duplicate the majority of the data - something I had to deal with quite often in the past - but there are a couple of variants that I'd like to ignore/skip.

Not implemented yet. Contribution is welcome.

@TeXitoi got a PR up that does it, I believe. Check it out and let me know.