Open
Description
Make sure you completed the following tasks
- Searched the discussionsSearched the closes issues
Describe your use case
The same as for Arg::display_order(usize)
and DeriveDisplayOrder
but should be easier to apply
Describe the solution you'd like
- Works well with
structopt
/clap_derive
flattening - Doesn't move both arguments to top or to the bottom like
.display_order
(because 999 is default for every argument). DeriveDisplayOrder
shouldn't override it
Alternatives, if applicable
Keep using Arg::display_order(usize)
and DeriveDisplayOrder
Additional context
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
kbknapp commentedon Apr 29, 2020
This might be pretty hairy to implement, especially if we end up trying to detect loops (
A
says display afterB
, andB
says display afterA
).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
DeriveDisplayOrder
work in your case? OrArg::help_heading
doesn't fit your use case?I60R commentedon May 6, 2020
Okay, I understand.
I actually use it. The problem was that it don't play well with
structopt
flattening, more specifically it doesn't allow to move argument into separate struct while keeping its order in --help message. This could be easilystructopt
problem, however it also seems that it occurs because currentdisplay_order
functionality inclap
is somehow limited.Arg::display_after
inclap
was simply the most straightforward solution here that I was able to imaginekbknapp commentedon May 11, 2020
Aaah ok, I understand. Yeah to me that sounds like either a feature/bug we could work on as part of
clap_derive
(what wasstructopt
).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.
pksunkara commentedon May 11, 2020
@I60R Could you provide us a sample code where it doesn't work? AFAIK, even flattening should make it work.
[-]Add display_after for easier arg positioning in --help message[/-][+]Better than display_order and DeriveDisplayOrder argument positioning[/+]I60R commentedon May 18, 2020
Done. I also think that I've found what argument positioning I want:
With
DeriveDisplayOrder
we increment each argdisplay_order
starting from 1000 but only for those that had it unspecified. Then, if multiple args sharing the samedisplay_order
they would be sorted alphabetically (default behavior).Instead or alongside with we may provide
display_all
method forApp
andArgGroup
which would be used like this:it could substitute
display_order
anddisplay
functions, plus add more styling options like custom section headers, separators, etc.@kbknapp is it possible to be implemented?
pksunkara commentedon May 18, 2020
We have them.
help_heading
.You are not exactly giving us a sample of the code where
DeriveDisplayOrder
is not working in clap_derive. As I said before, flattening the struct should work with the option well.I60R commentedon May 18, 2020
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:
and then refactors it to flattened
you may find that the original order is messed up (b-a-c) and there's no straightforward way to fix it
pksunkara commentedon May 19, 2020
Yes, that can be implemented.
53 remaining items