Skip to content

Commit 44709f6

Browse files
committed
fix(help): fix order of help output
1 parent 01cde99 commit 44709f6

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.2
55
toolchain go1.24.3
66

77
require (
8-
github.com/containeroo/dynflags v0.1.0
8+
github.com/containeroo/dynflags v0.1.1
99
github.com/containeroo/httputils v0.0.1
1010
github.com/containeroo/resolver v0.0.2
1111
github.com/spf13/pflag v1.0.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/containeroo/dynflags v0.1.0 h1:pWJx4rG3bznbtTDSaHQ9TpqRMPEmGX2e9D99zXP3Awg=
2-
github.com/containeroo/dynflags v0.1.0/go.mod h1:YmSfpL9trViFWdXOz+RUXQMTFiUBkcOeVajzoh+rMVw=
1+
github.com/containeroo/dynflags v0.1.1 h1:p6039AhBuKjfeylNwQwlQVsCEgufJDgFncrtCQmrjKE=
2+
github.com/containeroo/dynflags v0.1.1/go.mod h1:YmSfpL9trViFWdXOz+RUXQMTFiUBkcOeVajzoh+rMVw=
33
github.com/containeroo/httputils v0.0.1 h1:W9SbW6nbmnGgaEOXRH5nY9ZwLarBo3+FLUCx6EtS2mc=
44
github.com/containeroo/httputils v0.0.1/go.mod h1:TrmDptapH6SBe6CeHFWY2kxy63O/9ZWBWrLKpc2SFjI=
55
github.com/containeroo/resolver v0.0.2 h1:xvTA1N0Nr1g37TNRt2aS3HwivhztLCC+wTgHsYccwjk=

internal/config/config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,16 @@ func setupDynamicFlags() *dynflags.DynFlags {
136136
// setupUsage sets the custom usage function.
137137
func setupUsage(fs *flag.FlagSet, df *dynflags.DynFlags) {
138138
fs.Usage = func() {
139-
fmt.Fprintf(fs.Output(), "Usage: %s [FLAGS] [DYNAMIC FLAGS..]\n", strings.ToLower(fs.Name())) // nolint:errcheck
139+
out := fs.Output() // capture writer ONCE
140140

141-
fmt.Fprintln(fs.Output(), "\nGlobal Flags:") // nolint:errcheck
141+
fmt.Fprintf(out, "Usage: %s [FLAGS] [DYNAMIC FLAGS..]\n", strings.ToLower(fs.Name())) // nolint:errcheck
142+
143+
fmt.Fprintln(out, "\nGlobal Flags:") // nolint:errcheck
144+
fs.SetOutput(out)
142145
fs.PrintDefaults()
143146

144-
fmt.Fprintln(fs.Output(), "\nDynamic Flags:") // nolint:errcheck
147+
fmt.Fprintln(out, "\nDynamic Flags:") // nolint:errcheck
148+
df.SetOutput(out)
145149
df.PrintDefaults()
146150
}
147151
}

0 commit comments

Comments
 (0)