diff --git a/README.md b/README.md index cd4742b..a4ce0c3 100644 --- a/README.md +++ b/README.md @@ -599,7 +599,7 @@ The default help output is usually sufficient, but if not there are two solution 1. Use `ConfigureHelp(HelpOptions)` to configure how help is formatted (see [HelpOptions](https://godoc.org/github.com/alecthomas/kong#HelpOptions) for details). 2. Custom help can be wired into Kong via the `Help(HelpFunc)` option. The `HelpFunc` is passed a `Context`, which contains the parsed context for the current command-line. See the implementation of `PrintHelp` for an example. -3. Use `HelpFormatter(HelpValueFormatter)` if you want to just customize the help text that is accompanied by flags and arguments. +3. Use `ValueFormatter(HelpValueFormatter)` if you want to just customize the help text that is accompanied by flags and arguments. 4. Use `Groups([]Group)` if you want to customize group titles or add a header. ### `Bind(...)` - bind values for callback hooks and Run() methods diff --git a/help_test.go b/help_test.go index d907cc8..e0e9043 100644 --- a/help_test.go +++ b/help_test.go @@ -477,7 +477,7 @@ func TestEnvarAutoHelpWithEnvPrefix(t *testing.T) { require.Contains(t, w.String(), "A different flag.") } -func TestCustomHelpFormatter(t *testing.T) { +func TestCustomValueFormatter(t *testing.T) { var cli struct { Flag string `env:"FLAG" help:"A flag."` } @@ -485,7 +485,7 @@ func TestCustomHelpFormatter(t *testing.T) { p := mustNew(t, &cli, kong.Writers(w, w), kong.Exit(func(int) {}), - kong.HelpFormatter(func(value *kong.Value) string { + kong.ValueFormatter(func(value *kong.Value) string { return value.Help }), ) diff --git a/options.go b/options.go index 82d71d8..4c240ed 100644 --- a/options.go +++ b/options.go @@ -215,6 +215,8 @@ func ShortHelp(shortHelp HelpPrinter) Option { } // HelpFormatter configures how the help text is formatted. +// +// Deprecated: Use ValueFormatter() instead. func HelpFormatter(helpFormatter HelpValueFormatter) Option { return OptionFunc(func(k *Kong) error { k.helpFormatter = helpFormatter @@ -222,6 +224,14 @@ func HelpFormatter(helpFormatter HelpValueFormatter) Option { }) } +// ValueFormatter configures how the help text is formatted. +func ValueFormatter(helpFormatter HelpValueFormatter) Option { + return OptionFunc(func(k *Kong) error { + k.helpFormatter = helpFormatter + return nil + }) +} + // ConfigureHelp sets the HelpOptions to use for printing help. func ConfigureHelp(options HelpOptions) Option { return OptionFunc(func(k *Kong) error {