clagraff / argparse

A Golang argument parser for command line arguments.
MIT License
24 stars 4 forks source link

Upper-case options shown as lower-case in help text. #48

Closed TheHippoMan closed 1 year ago

TheHippoMan commented 1 year ago

I'm very happy with this argparse package! Thank you for your excellent work.

I just found one very tiny issue:

I want to specify a command-line option that can take 4 values: "-r", "-R", "--recurse", and "--recursive". I know that I can do so as follows:

recursiveFlag := argparse.NewFlag("r R recurse recursive", "recursive", "Run recursively").Default("false")

This works perfectly when I run the program: all possibilities for the option are indeed accepted. However, if the "help" text is printed, the following shows up in the "optional arguments:" section ...

-r, -r, --recurse, --recursive Run recursively

In other words, the "-R" option is translated to lower case in this "help" text.

Again, I know that the command-line parser itself handles this correctly, because if I leave "R" out of the NewFlag() function call, then "-R" is no longer accepted by the command-line parser.

This is nothing more than a small issue with the rendering of the "help" text.

clagraff commented 1 year ago

Wow, thanks @TheHippoMan for the kind feedback & detailed bug report. I am surprised to hear someone else has gotten use outta this package besides myself. That's neat.

Thanks for submitting an issue about this. I'll take a gander, I think think I know what the problem is.

clagraff commented 1 year ago

@TheHippoMan should be all set. Updated to respect the casing of the option flags. Also added a test for this scenario. Seems to be working, bumped up the versions for the repo. Lmk if you have any other issues.

TheHippoMan commented 1 year ago

Thank you!