From 38e5c6198ed71153d8d3dc77d0ef7d75b19b679a Mon Sep 17 00:00:00 2001 From: Alex Broad <46813168+alex-broad@users.noreply.github.com> Date: Mon, 27 May 2024 12:02:24 +0100 Subject: [PATCH] Update help example to use vars (#429) --- _examples/shell/help/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/_examples/shell/help/main.go b/_examples/shell/help/main.go index 56b8ce6..4d1d154 100644 --- a/_examples/shell/help/main.go +++ b/_examples/shell/help/main.go @@ -7,14 +7,16 @@ import ( ) var cli struct { - Flag flagWithHelp `help:"Regular flag help"` + Flag flagWithHelp `help:"${flag_help}"` Echo commandWithHelp `cmd:"" help:"Regular command help"` } type flagWithHelp bool -func (f *flagWithHelp) Help() string { - return "🏁 additional flag help" +// See https://github.com/alecthomas/kong?tab=readme-ov-file#variable-interpolation +var vars = kong.Vars{ + "flag_help": "Extended flag help that might be too long for directly " + + "including in the struct tag field", } type commandWithHelp struct { @@ -41,7 +43,8 @@ func main() { kong.ConfigureHelp(kong.HelpOptions{ Compact: true, Summary: false, - })) + }), + vars) switch ctx.Command() { case "echo ": fmt.Println(cli.Echo.Msg)