Skip to content

Commit

Permalink
fix: duplicate usage output (#786)
Browse files Browse the repository at this point in the history
When a `*pflag.FlagSet` is parsed, it outputs a usage string if the
`--help` flag is included. Since Cobra already does this, this behavior
needs to be disabled or the usage will be printed twice.

---

Since #736 hasn't been release yet, this fix shouldn't appear in the
changelog.

BEGIN_COMMIT_OVERRIDE
feat: new configuration system, config subcommand 
END_COMMIT_OVERRIDE
  • Loading branch information
phm07 authored Jun 20, 2024
1 parent b9f4b24 commit b4df982
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/state/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (cfg *config) reset() {
cfg.v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))

cfg.fs = pflag.NewFlagSet("hcloud", pflag.ContinueOnError)
cfg.fs.Usage = func() {} // disable usage output
for _, o := range Options {
o.addToFlagSet(cfg.fs)
}
Expand Down

0 comments on commit b4df982

Please sign in to comment.