@@ -21,7 +21,7 @@ func (h helpFlag) IgnoreDefault() {}
2121func (h helpFlag ) BeforeReset (ctx * Context ) error {
2222 options := ctx .Kong .helpOptions
2323 options .Summary = false
24- err := ctx .Kong . help (options , ctx )
24+ err := ctx .printHelp (options )
2525 if err != nil {
2626 return err
2727 }
@@ -58,6 +58,9 @@ type HelpOptions struct {
5858 // If this is set to a non-positive number, the terminal width is used; otherwise,
5959 // the min of this value or the terminal width is used.
6060 WrapUpperBound int
61+
62+ // ValueFormatter is used to format the help text of flags and positional arguments.
63+ ValueFormatter HelpValueFormatter
6164}
6265
6366// Apply options to Kong as a configuration option.
@@ -365,10 +368,9 @@ func printCommandSummary(w *helpWriter, cmd *Command) {
365368}
366369
367370type helpWriter struct {
368- indent string
369- width int
370- lines * []string
371- helpFormatter HelpValueFormatter
371+ indent string
372+ width int
373+ lines * []string
372374 HelpOptions
373375}
374376
@@ -379,11 +381,10 @@ func newHelpWriter(ctx *Context, options HelpOptions) *helpWriter {
379381 wrapWidth = options .WrapUpperBound
380382 }
381383 w := & helpWriter {
382- indent : "" ,
383- width : wrapWidth ,
384- lines : & lines ,
385- helpFormatter : ctx .Kong .helpFormatter ,
386- HelpOptions : options ,
384+ indent : "" ,
385+ width : wrapWidth ,
386+ lines : & lines ,
387+ HelpOptions : options ,
387388 }
388389 return w
389390}
@@ -398,7 +399,7 @@ func (h *helpWriter) Print(text string) {
398399
399400// Indent returns a new helpWriter indented by two characters.
400401func (h * helpWriter ) Indent () * helpWriter {
401- return & helpWriter {indent : h .indent + " " , lines : h .lines , width : h .width - 2 , HelpOptions : h .HelpOptions , helpFormatter : h . helpFormatter }
402+ return & helpWriter {indent : h .indent + " " , lines : h .lines , width : h .width - 2 , HelpOptions : h .HelpOptions }
402403}
403404
404405func (h * helpWriter ) String () string {
@@ -426,7 +427,7 @@ func (h *helpWriter) Wrap(text string) {
426427func writePositionals (w * helpWriter , args []* Positional ) {
427428 rows := [][2 ]string {}
428429 for _ , arg := range args {
429- rows = append (rows , [2 ]string {arg .Summary (), w .helpFormatter (arg )})
430+ rows = append (rows , [2 ]string {arg .Summary (), w .HelpOptions . ValueFormatter (arg )})
430431 }
431432 writeTwoColumns (w , rows )
432433}
@@ -448,7 +449,7 @@ func writeFlags(w *helpWriter, groups [][]*Flag) {
448449 }
449450 for _ , flag := range group {
450451 if ! flag .Hidden {
451- rows = append (rows , [2 ]string {formatFlag (haveShort , flag ), w .helpFormatter (flag .Value )})
452+ rows = append (rows , [2 ]string {formatFlag (haveShort , flag ), w .HelpOptions . ValueFormatter (flag .Value )})
452453 }
453454 }
454455 }
0 commit comments