cli icon indicating copy to clipboard operation
cli copied to clipboard

How to stop flag from sorting automatically for --help?

Open FGYFFFF opened this issue 2 years ago • 4 comments

Previously I was using "github.com/urfave/cli" v1 and when I entered --help it displayed the flags in the order I filled them in, but when I used v2 all the flags were automatically sorted, how can I stop the automatic sorting? I didn't find any place where I can set it.

FGYFFFF avatar Jun 16 '22 08:06 FGYFFFF

@FGYFFFF This behavior was introduced recently in the v2 series via flag category support. Given that there's an expectation that the default sort order should not be by name, I'd like to explore reverting to the previous behavior. Is this something you're willing and able to contribute?

meatballhat avatar Jun 18 '22 13:06 meatballhat

Yes,I am willing to do it

FGYFFFF avatar Jun 19 '22 04:06 FGYFFFF

@FGYFFFF Great! Thank you!

meatballhat avatar Jun 19 '22 14:06 meatballhat

Looking at this again, I think the change to automatically sorting the flags is arguably a regression because the current documentation claims that the default ordering is not sorted.:

https://cli.urfave.org/v2/#ordering

meatballhat avatar Jun 20 '22 18:06 meatballhat

Fixed in release v2.19.2

dearchap avatar Oct 10 '22 01:10 dearchap