chore(deps): bump github.com/alecthomas/kong from 1.12.1 to 1.13.0

Bumps [github.com/alecthomas/kong](https://github.com/alecthomas/kong) from 1.12.1 to 1.13.0.
- [Commits](https://github.com/alecthomas/kong/compare/v1.12.1...v1.13.0)

---
updated-dependencies:
- dependency-name: github.com/alecthomas/kong
  dependency-version: 1.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-11-14 07:01:30 +00:00
committed by GitHub
parent cfc7fdb6b8
commit 62439693fb
6 changed files with 31 additions and 22 deletions

2
go.mod
View File

@@ -6,7 +6,7 @@ require (
dario.cat/mergo v1.0.2
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.33
github.com/alecthomas/kong v1.12.1
github.com/alecthomas/kong v1.13.0
github.com/bmatcuk/doublestar/v3 v3.0.0
github.com/containerd/platforms v1.0.0-rc.1
github.com/crazy-max/cron/v3 v3.1.1

8
go.sum
View File

@@ -26,10 +26,10 @@ github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7l
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/kong v1.12.1 h1:iq6aMJDcFYP9uFrLdsiZQ2ZMmcshduyGv4Pek0MQPW0=
github.com/alecthomas/kong v1.12.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/alecthomas/kong v1.13.0 h1:5e/7XC3ugvhP1DQBmTS+WuHtCbcv44hsohMgcvVxSrA=
github.com/alecthomas/kong v1.13.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I=
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=

View File

@@ -883,6 +883,11 @@ func (c *Context) Run(binds ...any) (err error) {
func (c *Context) PrintUsage(summary bool) error {
options := c.helpOptions
options.Summary = summary
return c.printHelp(options)
}
func (c *Context) printHelp(options HelpOptions) error {
options.ValueFormatter = c.Kong.helpFormatter
return c.help(options, c)
}

View File

@@ -21,7 +21,7 @@ func (h helpFlag) IgnoreDefault() {}
func (h helpFlag) BeforeReset(ctx *Context) error {
options := ctx.Kong.helpOptions
options.Summary = false
err := ctx.Kong.help(options, ctx)
err := ctx.printHelp(options)
if err != nil {
return err
}
@@ -58,6 +58,9 @@ type HelpOptions struct {
// If this is set to a non-positive number, the terminal width is used; otherwise,
// the min of this value or the terminal width is used.
WrapUpperBound int
// ValueFormatter is used to format the help text of flags and positional arguments.
ValueFormatter HelpValueFormatter
}
// Apply options to Kong as a configuration option.
@@ -365,10 +368,9 @@ func printCommandSummary(w *helpWriter, cmd *Command) {
}
type helpWriter struct {
indent string
width int
lines *[]string
helpFormatter HelpValueFormatter
indent string
width int
lines *[]string
HelpOptions
}
@@ -379,11 +381,10 @@ func newHelpWriter(ctx *Context, options HelpOptions) *helpWriter {
wrapWidth = options.WrapUpperBound
}
w := &helpWriter{
indent: "",
width: wrapWidth,
lines: &lines,
helpFormatter: ctx.Kong.helpFormatter,
HelpOptions: options,
indent: "",
width: wrapWidth,
lines: &lines,
HelpOptions: options,
}
return w
}
@@ -398,7 +399,7 @@ func (h *helpWriter) Print(text string) {
// Indent returns a new helpWriter indented by two characters.
func (h *helpWriter) Indent() *helpWriter {
return &helpWriter{indent: h.indent + " ", lines: h.lines, width: h.width - 2, HelpOptions: h.HelpOptions, helpFormatter: h.helpFormatter}
return &helpWriter{indent: h.indent + " ", lines: h.lines, width: h.width - 2, HelpOptions: h.HelpOptions}
}
func (h *helpWriter) String() string {
@@ -426,7 +427,7 @@ func (h *helpWriter) Wrap(text string) {
func writePositionals(w *helpWriter, args []*Positional) {
rows := [][2]string{}
for _, arg := range args {
rows = append(rows, [2]string{arg.Summary(), w.helpFormatter(arg)})
rows = append(rows, [2]string{arg.Summary(), w.HelpOptions.ValueFormatter(arg)})
}
writeTwoColumns(w, rows)
}
@@ -448,7 +449,7 @@ func writeFlags(w *helpWriter, groups [][]*Flag) {
}
for _, flag := range group {
if !flag.Hidden {
rows = append(rows, [2]string{formatFlag(haveShort, flag), w.helpFormatter(flag.Value)})
rows = append(rows, [2]string{formatFlag(haveShort, flag), w.HelpOptions.ValueFormatter(flag.Value)})
}
}
}

View File

@@ -249,8 +249,11 @@ func (k *Kong) interpolateValue(value *Value, vars Vars) (err error) {
vars = vars.CloneWith(varsContributor.Vars(value))
}
if value.Enum, err = interpolate(value.Enum, vars, nil); err != nil {
return fmt.Errorf("enum for %s: %s", value.Summary(), err)
initialVars := vars.CloneWith(nil)
for n, v := range initialVars {
if vars[n], err = interpolate(v, initialVars, nil); err != nil {
return fmt.Errorf("variable %s for %s: %s", n, value.Summary(), err)
}
}
if value.Default, err = interpolate(value.Default, vars, nil); err != nil {
@@ -469,7 +472,7 @@ func (k *Kong) FatalIfErrorf(err error, args ...any) {
if errors.As(err, &parseErr) {
switch k.usageOnError {
case fullUsage:
_ = k.help(k.helpOptions, parseErr.Context)
_ = parseErr.Context.printHelp(k.helpOptions)
fmt.Fprintln(k.Stdout)
case shortUsage:
_ = k.shortHelp(k.helpOptions, parseErr.Context)

2
vendor/modules.txt vendored
View File

@@ -38,7 +38,7 @@ github.com/PuerkitoBio/goquery
# github.com/agext/levenshtein v1.2.3
## explicit
github.com/agext/levenshtein
# github.com/alecthomas/kong v1.12.1
# github.com/alecthomas/kong v1.13.0
## explicit; go 1.20
github.com/alecthomas/kong
# github.com/andybalholm/cascadia v1.3.2