From c69b9a1e8883d999276778e1af26f1cd3ea1e96f Mon Sep 17 00:00:00 2001 From: Freestate17 Date: Mon, 4 May 2020 18:14:33 -0400 Subject: [PATCH] added post-build option (#78) * added post-build option * updated PostBuild function description Co-authored-by: Daniel Lins --- options.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/options.go b/options.go index 1464d71..e210d10 100644 --- a/options.go +++ b/options.go @@ -61,6 +61,17 @@ func NoDefaultHelp() Option { }) } +// PostBuild provides read/write access to kong.Kong after initial construction of the model is complete but before +// parsing occurs. +// +// This is useful for, e.g., adding short options to flags, updating help, etc. +func (k *Kong) PostBuild(fn func(*Kong)error) Option { + return OptionFunc(func (k *Kong) error { + k.postBuildOptions = append(k.postBuildOptions, OptionFunc(fn)) + return nil + }) +} + // Name overrides the application name. func Name(name string) Option { return OptionFunc(func(k *Kong) error {