Skip to content

Commit c5e464a

Browse files
committed
Deprecate HelpFormatter.
1 parent c3703cd commit c5e464a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ The default help output is usually sufficient, but if not there are two solution
599599

600600
1. Use `ConfigureHelp(HelpOptions)` to configure how help is formatted (see [HelpOptions](https://godoc.org/github.com/alecthomas/kong#HelpOptions) for details).
601601
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.
602-
3. Use `HelpFormatter(HelpValueFormatter)` if you want to just customize the help text that is accompanied by flags and arguments.
602+
3. Use `ValueFormatter(HelpValueFormatter)` if you want to just customize the help text that is accompanied by flags and arguments.
603603
4. Use `Groups([]Group)` if you want to customize group titles or add a header.
604604

605605
### `Bind(...)` - bind values for callback hooks and Run() methods

help_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,15 @@ func TestEnvarAutoHelpWithEnvPrefix(t *testing.T) {
477477
require.Contains(t, w.String(), "A different flag.")
478478
}
479479

480-
func TestCustomHelpFormatter(t *testing.T) {
480+
func TestCustomValueFormatter(t *testing.T) {
481481
var cli struct {
482482
Flag string `env:"FLAG" help:"A flag."`
483483
}
484484
w := &strings.Builder{}
485485
p := mustNew(t, &cli,
486486
kong.Writers(w, w),
487487
kong.Exit(func(int) {}),
488-
kong.HelpFormatter(func(value *kong.Value) string {
488+
kong.ValueFormatter(func(value *kong.Value) string {
489489
return value.Help
490490
}),
491491
)

options.go

+10
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,23 @@ func ShortHelp(shortHelp HelpPrinter) Option {
215215
}
216216

217217
// HelpFormatter configures how the help text is formatted.
218+
//
219+
// Deprecated: Use ValueFormatter() instead.
218220
func HelpFormatter(helpFormatter HelpValueFormatter) Option {
219221
return OptionFunc(func(k *Kong) error {
220222
k.helpFormatter = helpFormatter
221223
return nil
222224
})
223225
}
224226

227+
// ValueFormatter configures how the help text is formatted.
228+
func ValueFormatter(helpFormatter HelpValueFormatter) Option {
229+
return OptionFunc(func(k *Kong) error {
230+
k.helpFormatter = helpFormatter
231+
return nil
232+
})
233+
}
234+
225235
// ConfigureHelp sets the HelpOptions to use for printing help.
226236
func ConfigureHelp(options HelpOptions) Option {
227237
return OptionFunc(func(k *Kong) error {

0 commit comments

Comments
 (0)