jessevdk / go-flags

go command line option parser
http://godoc.org/github.com/jessevdk/go-flags
BSD 3-Clause "New" or "Revised" License
2.56k stars 305 forks source link

Fix single choice support #388

Closed denisvmedia closed 1 year ago

denisvmedia commented 2 years ago

This PR fixes a situation when there is only once choice available. Normally, we probably wouldn't expect it. But it can be in a situation where the software is being actively developed and some feature is being added with future possible extension. Thus giving a single option could be a valid situation.

Currently, if you pass an incorrect option to a single-optioned parameter, you will get an error with an empty list of possible values: Allowed values are:. This PR adds that single value to the list.

In addition, this PR adds some tests and fixes broken tests as well (if you think the fix for the broken tests is excessive, I can remove it).