Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1183 from weaveworks/issue/1176-deal-with-help
Browse files Browse the repository at this point in the history
Update pflag to avoid flag parsing gotchas
  • Loading branch information
squaremo authored Jul 4, 2018
2 parents 2d58c32 + 71035b2 commit dfa97ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ func main() {
dockerConfig = fs.String("docker-config", "", "path to a docker config to use for image registry credentials")
)

if err := fs.Parse(os.Args[1:]); err != nil {
err := fs.Parse(os.Args[1:])
switch {
case err == pflag.ErrHelp:
os.Exit(0)
case err != nil:
fmt.Fprintf(os.Stderr, "Error: %s\n\n", err.Error())
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fs.PrintDefaults()
fs.Usage()
os.Exit(2)
}

if *versionFlag {
case *versionFlag:
fmt.Println(version)
os.Exit(0)
}
Expand Down

0 comments on commit dfa97ba

Please sign in to comment.