decred / vspd

A Voting Service Provider (VSP) for the Decred network.
ISC License
19 stars 20 forks source link

multi: Explicitly handle help requests. #469

Closed jholdstock closed 4 months ago

jholdstock commented 4 months ago

Checking for --help as an explicit step before parsing any other configs makes the code more intuitive by removing a convoluted bit of error handling, which happened to be unnecessarily duplicated in three places.

Moving it to a function in the internal package makes it reusable by multiple binaries.

This also enables the IgnoreUnknown option to be used whilst parsing for help, which ensures the presence of --help will always result in the help message being printed. This fixes a minor inconsistency where the help message would be printed if the flag was placed before an invalid config, but placing it after would cause an invalid config error to be written instead. For example, vspd --help --fakeflag vs vspd --fakeflag --help.