bash-argsparse icon indicating copy to clipboard operation
bash-argsparse copied to clipboard

unstable order in generated usage

Open warpfork opened this issue 3 months ago • 1 comments

The order of flags described in the generated usage appears to be random. (I guess it is effectively the iteration order of the bash associative maps.)

For example, the current output of one of the tutorial scripts is:

6-properties [ --option8 ] [ --option3 ] --option1 [ --option6 ] [ --option7 ] \
	[ --option4 ] [ --option5 ] [ --help ]

      --option8   A 8th option
		 Requires: --option2 --option3
      --option3   A 3rd option.
      --option1   A mandatory option.
      --option6   A 6th option.
		 Same as: --option1 --option2 --option3
      --option7   A 7th option
		 Same as: --option6
      --option4   A 4th option.
      --option5   A 5th option.
 -h | --help      Show this help message

This is moderately confusing. Either sorted, or persisting the order in which they are defined, would be preferable.

warpfork avatar Nov 23 '25 14:11 warpfork

Hello. Thanks for the report.

Sorting the options as built-in would be a pain (zsh has some built-in sorting feature, bash does not, afaik). And using the sort command would probably require supporting the non-GNU variations.

I don't think I will do it, unless someone can provide a solution... ?

Anvil avatar Nov 27 '25 09:11 Anvil