Skip to content
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

Add a skip or hide property #52

Open
asomers opened this issue Jul 15, 2021 · 0 comments
Open

Add a skip or hide property #52

asomers opened this issue Jul 15, 2021 · 0 comments

Comments

@asomers
Copy link

asomers commented Jul 15, 2021

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>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant