jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
502 stars 47 forks source link

--help option is not handled correctly #144

Closed nilskuhn closed 3 months ago

nilskuhn commented 4 months ago

Describe the bug When running goverters help command via flag --help, it prints out the following:

$ goverter --help             
Error: unknown command: --help
Usage:
...

The bad thing is, that its return code is non-zero.

To Reproduce Run goverter with help command:

goverter --help
echo $?

Return code is 1.

Expected behavior Goverter help message should be shown without an error message and the return code should be 0.

The bad thing about this is that there isn't even a version command, so no option to call goverter in a noop way to do an optional installation like this:

goverter -h >/dev/null 2>&1 || go install github.com/jmattheis/goverter/cmd/goverter@latest
jmattheis commented 4 months ago

Good catch, as a workaround you can use command -v to check if a command exists:

command -v goverter || go install github.com/jmattheis/goverter/cmd/goverter@latest
nilskuhn commented 4 months ago

thanks, wasn't aware of command shell builtin