Skip to content

Can't figure out Help() for arg #523

@ybizeul

Description

@ybizeul

I'm basically trying to document a complex arg with Help() to no avail.

package main

import "github.com/alecthomas/kong"

var CLI struct {
	CmdTest commandWithHelp `cmd:""`
}

type commandWithHelp struct {
	Test argumentWithHelp `arg:"" help:"Test"`
}

type argumentWithHelp struct {
	Test string `arg:""`
}

func (u *argumentWithHelp) Help() string {
	return `Some longer text`
}

func (u *commandWithHelp) Run(ctx *kong.Context) error {
	return nil
}

func main() {

	ctx := kong.Parse(&CLI, kong.ConfigureHelp(kong.HelpOptions{
		Compact: true,
		Summary: false,
	}))
	_ = ctx.Run()
}
❯ go run . cmd-test -h
Usage: kongtest cmd-test <command>

Flags:
  -h, --help    Show context-sensitive help.

Commands:
  cmd-test <test>    Test
  1. For some reason, kong thinks that cmd-test has a cmd-test subcommand
  2. Long description for test isn't called or displayed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions