Skip to content

Add a skip or hide property #52

@asomers

Description

@asomers

Would it be possible to add an option to gumdrop_derive that skips one of the struct's fields? Or if not, one that hides it from the help menu?

My motivation is to combine gumdrop with confy on a single struct. Most options should be configurable either from the command line or from the config file, but a few options are only relevant for one or the other. Here's an example of how to use such an option:

#[derive(Debug, Default, Deserialize, Options, Serialize)]
struct Config {
    #[options(help = "print help message")]
    // it makes no sense to set --help in the config file
    #[serde(skip)]
    help: bool,
    /// Thread pool size
    // This one makes sense both both config file and CLI
    #[options(default = "1")]
    threads: i32,
    /// Specify the server's parameters in JSON
    // This field is too complicated for the command-line.  Only enable it in the config file
    #[options(skip)]
    serverspec: Option<String>
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions