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

Nested types (flatten args) #21

Open
Alxandr opened this issue Jul 19, 2019 · 2 comments
Open

Nested types (flatten args) #21

Alxandr opened this issue Jul 19, 2019 · 2 comments

Comments

@Alxandr
Copy link

Alxandr commented Jul 19, 2019

It would be really nice if the following worked, in order to enable re-use of options between multiple commands:

#[derive(Options)]
struct CommonOpts {
  foo: bool,
}

#[derive(Options)]
struct Opts {
  bar: bool,

  #[options(flatten)]
  common: CommonOpts,
}

// call using `program --foo --bar`
@murarth
Copy link
Owner

murarth commented Jul 19, 2019

This would be nice, but it's looking rather tricky to implement given the code currently generated for Options::parse, which is kind of a mess (see here).

However, I'd like to keep this issue open to remind me to implement this feature as part of a future refactor.

@Alxandr
Copy link
Author

Alxandr commented Jul 19, 2019

Yeah. I tried doing manually (ie, not using derive), but I gave up mostly due to &'static str return types all over the place. Went back to structopt for now.

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

2 participants