cobra
cobra copied to clipboard
Persistent flags alone can't disable the ordering properly
It looks like the disable ordering feature is not working with commands with persistent flags only. But works fine if commands have local flags or both local and persistent flags.
I have a root command with only persistent flags. And even I set SortFlags = false
, the command still prints the flags in order.
...
pFlags := c.PersistentFlags()
pFlags.SortFlags = false
pFlags.String("z", "Z", "")
pFlags.String("a", "A", "")
...
And I got
...
Flags:
--a string (default "A")
--z string (default "Z")
...
If you also set Flags().SortFlags to false, even without defining local flags, then the sorting will be disabled
...
c.Flags().SortFlags = false
pFlags := c.PersistentFlags
...
This issue is being marked as stale due to a long period of inactivity
Hey :wave: any plans around fixing this issue?