Skip to content

Custom shell completion doesn't work #2333

@TLINDEN

Description

@TLINDEN

My urfave/cli version is

v3.9.0

Checklist

  • Are you running the latest v3 release? The list of releases is here.
  • Did you check the manual for your release? The v3 manual is here
  • Did you perform a search about this problem? Here's the GitHub guide about searching.

Dependency Management

  • My project is using go modules.

Describe the bug

I have added a custom completion to a subcommand but when I reach this point in a completion sequence only files are being completed, the custom completion is not even being called.

To reproduce

This is the subcommand:

func IndexShow(conf *cfg.Config) *cli.Command {
	return &cli.Command{
		Name:    "show",
		Aliases: []string{"sh"},
		Usage:   "show details about an index",

		Action: func(ctx context.Context, cmd *cli.Command) error {
			return es.IndexShow(conf, cmd.Args().Get(0))
		},

		ShellComplete: func(ctx context.Context, cmd *cli.Command) {
			if cmd.NArg() > 0 {
				return
			}

			indices, err := es.IndexNames(conf)
			if err != nil {
				return
			}

			for _, index := range indices {
				fmt.Println(index)
			}
		},
	}
}

Observed behavior

Nothing happens. Even if I add a panic(0) at the start of the custom completion func, it doesn't panic, so it's not being called.

Expected behavior

I'd expect to get a completion of the custom list printed, see above.

Additional context

Source: https://codeberg.org/scip/esctl/src/branch/main/cmd/index.go#L78

Run go version and paste its output here

go1.23.5 linux/amd64

Run go env and paste its output here

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/scip/.cache/go-build'
GOENV='/home/scip/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/scip/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/scip/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.5'
GODEBUG=''
GOTELEMETRY='off'
GOTELEMETRYDIR='/home/scip/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3675849324=/tmp/go-build -gno-record-gcc-switches'

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v3relates to / is being considered for v3kind/bugdescribes or fixes a bugstatus/triagemaintainers still need to look into this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions