Skip to content

Commit

Permalink
chore: update help template to run full initializers (#22)
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Zantow <[email protected]>
  • Loading branch information
kzantow authored Aug 23, 2023
1 parent 316385f commit 189155e
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions help_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func showConfigInRootHelp(a *application) {
// note: since all commands tend to share help functions it's important to only patch the example
// when there is no parent command (i.e. the root command).
if cmd == a.root {
cfgs := append([]any{&appInitializer{a: a}, &a.state.Config}, a.state.Config.FromCommands...)
cfgs := append([]any{&a.state.Config, a}, a.state.Config.FromCommands...)
for _, cfg := range cfgs {
// load each config individually, as there may be conflicting names / types that will cause
// viper to fail to read them all and panic
Expand All @@ -74,13 +74,3 @@ func showConfigInRootHelp(a *application) {
helpFn(cmd, args)
})
}

type appInitializer struct {
a *application
}

var _ fangs.PostLoader = (*appInitializer)(nil)

func (a *appInitializer) PostLoad() error {
return a.a.runInitializers()
}

0 comments on commit 189155e

Please sign in to comment.