-
Notifications
You must be signed in to change notification settings - Fork 0
Better than display_order and DeriveDisplayOrder argument positioning #153
Comments
Comment by kbknapp This might be pretty hairy to implement, especially if we end up trying to detect loops ( I'm leaning towards closing this feature, as it'd significantly impact the code used to generate help messages for (my subjectively) little benefit. @I60R could you elaborate on why doesn't |
Comment by I60R
Okay, I understand.
I actually use it. The problem was that it don't play well with
|
Comment by kbknapp
Aaah ok, I understand. Yeah to me that sounds like either a feature/bug we could work on as part of I'm open to others opinions as well, but even when flattening the order should be preserved. That sounds like a new issue to me, or perhaps we re-name this issue and update the OP with this new constraint/requirement. |
Comment by I60R
Done. I also think that I've found what argument positioning I want:
display_all = &[
("FLAGS", &[
"first",
"second",
"x",
...
]),
("OPTIONS", &[
"nth",
"nth+1",
...
]),
...,
("CUSTOM SECTION", &[
...,
"last-1",
"last"
])
], it could substitute @kbknapp is it possible to be implemented? |
Comment by pksunkara
We have them.
You are not exactly giving us a sample of the code where |
Comment by I60R
The whole point isn't in having them, but in having them in the same place and not using them explicitly.
That's actually the problem e.g. if you have this unflattened struct: #[derive(StructOpt)]
#[structopt(global_settings=&[DeriveDisplayOrder])]
struct Opt {
a: bool,
b: bool,
c: bool,
...
} and then refactors it to flattened #[derive(StructOpt)]
#[structopt(global_settings=&[DeriveDisplayOrder])]
struct Opt {
b: bool,
#[structopt(flatten)]
flattened: Flattened,
...
}
#[derive(StructOpt)]
struct Flattened {
a: bool,
c: bool,
} you may find that the original order is messed up (b-a-c) and there's no straightforward way to fix it |
Comment by pksunkara
Yes, that can be implemented. |
Issue by I60R
Saturday Apr 11, 2020 at 14:06 GMT
Originally opened as clap-rs/clap#1807
Make sure you completed the following tasks
Describe your use case
The same as for
Arg::display_order(usize)
andDeriveDisplayOrder
but should be easier to applyDescribe the solution you'd like
structopt
/clap_derive
flattening.display_order
(because 999 is default for every argument).DeriveDisplayOrder
shouldn't override itAlternatives, if applicable
Keep using
Arg::display_order(usize)
andDeriveDisplayOrder
Additional context
The text was updated successfully, but these errors were encountered: