Skip to content

v3 fish completions completion inside hidden commands don't work #2120

@bittrance

Description

@bittrance

My urfave/cli version is

53ad542

Describe the bug

Fish completions only traverse into commands in cmd.VisibleCommands() so there will be no completions for anything "under" a hidden command.

To reproduce

	app := &cli.Command{
		Name:                  "mycli",
		Version:               "1.0.0",
		Usage:                 "Pure awesomeness.",
		EnableShellCompletion: true,
		Suggest:               true,
		Commands: []*cli.Command{
			{
				Name:   "more-awesome",
				Hidden: true,
				Action: func(ctx context.Context, cmd *cli.Command) error {
					return nil
				},
				Flags: []cli.Flag{
					&cli.StringFlag{
						Name:      "increase",
					},
				},
			},
		},
	}

Observed behavior

This gives no completions:

mycli more-awesome -- <tab>

Expected behavior

Reasonably, once you have entered the secret command, there should be completions again as normal. The bash completions seems to work like that.

Want to fix this yourself?

PR pending.

Run go version and paste its output here

go version go1.23.8 linux/amd64

Run go env and paste its output here

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/andqvi/.cache/go-build'
GOENV='/home/andqvi/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/andqvi/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/andqvi/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/andqvi/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.8.linux-amd64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/andqvi/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.8.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.8'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/andqvi/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/andqvi/projects/external/harness-cli/go.mod'
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-build320049062=/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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions