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

Sorting of flags #69

Open
syacko opened this issue Jun 17, 2020 · 5 comments
Open

Sorting of flags #69

syacko opened this issue Jun 17, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@syacko
Copy link

syacko commented Jun 17, 2020

I have reviewed the documentation and I don't see a way to sort the out put of the flags when -h(elp) is used. Is this possible and if not, is it something that can be added?

@syacko
Copy link
Author

syacko commented Jun 17, 2020

After experimenting, the flags are listed in the order they appear in the code. Please confirm that is correct.

@integrii
Copy link
Owner

I am not sure if how flags are listed is always the same (or always based on the code), actually, but we could add sorting to them - it's probably relatively easy... Right before the flags are templated out into the help display, we could do some analysis that sorts their order in the slice.

It is likely the case that flags are almost always displayed in the order that they are appended, but flags that are inherited from parent subcommands may break this rule... That is, flags that are part of a parent subcommand may come out before or after depending on how the code runs.

What kind of flag output sorting would you prefer to see?

@integrii integrii self-assigned this Jun 22, 2020
@syacko
Copy link
Author

syacko commented Jun 22, 2020

Thanks for the reply. A simple A-Z or Z-A would be great by the long name.

@integrii integrii added the enhancement New feature or request label Jul 15, 2020
@integrii
Copy link
Owner

We could add a couple calls to flaggy that enable flag output sorting. Then, right before output, we sort depending on which sorting method was chosen.

flaggy.SortFlagsByLongName()
flaggy.SortFlagsByLongNameReversed()
...

@soteadmin
Copy link

Thank sounds great. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants