-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/pwru: Implement a proper help function
With "./pwru --help" or "./pwru -h", pwru: 1. displays the help message, 2. prints "pflag: help requested", 3. exits with error code 2. Steps 2 and 3 are not expected, the interactive help should return 0 without displaying an error message. This is because of how pflags.ParseAll() works. From its documentation [0]: "The return value will be ErrHelp if -help was set but not defined." Let's implement a dedicated function for displaying the help message (reusing pflags.Usage() and what we had in pwru already), and call it when users pass --help or -h to avoid this error and non-zero return value. [0] https://pkg.go.dev/github.com/spf13/pflag#FlagSet.ParseAll Signed-off-by: Quentin Monnet <[email protected]>
- Loading branch information
Showing
3 changed files
with
11 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters