murarth / gumdrop

Rust option parser with custom derive support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a skip or hide property

asomers opened this issue · comments

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>
}