gumdrop icon indicating copy to clipboard operation
gumdrop copied to clipboard

Nested types (flatten args)

Open Alxandr opened this issue 6 years ago • 2 comments

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`

Alxandr avatar Jul 19 '19 17:07 Alxandr

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.

murarth avatar Jul 19 '19 21:07 murarth

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.

Alxandr avatar Jul 19 '19 21:07 Alxandr