Files
kong/defaults.go
2024-12-29 08:10:34 +09:00

22 lines
389 B
Go

package kong
// ApplyDefaults if they are not already set.
func ApplyDefaults(target any, options ...Option) error {
app, err := New(target, options...)
if err != nil {
return err
}
ctx, err := Trace(app, nil)
if err != nil {
return err
}
err = ctx.Resolve()
if err != nil {
return err
}
if err = ctx.ApplyDefaults(); err != nil {
return err
}
return ctx.Validate()
}