Skip to content

Auto-completion with unfinished partial flags (--XXX<TAB> returns no completions #2248

@TimSoethout

Description

@TimSoethout

My urfave/cli version is

v3.6.1

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

When passing in uncompleted flags (--XXX<TAB>), no auto-completion is available.

To reproduce

In a project with autocompletions enabled with command and arguments run:

$ command <TAB>
subcommand
$ command subcommand -<TAB>
--par1
--par2
--flag
$command subcommand --pa<TAB>
* empty

Underlying I see respectively begin passed to the binary:

  • --generate-shell-completion, returns list of commands
  • - --generate-shell-completion returns list of flags
  • --pa --generate-shell-completion, but this one is empty

Observed behavior

No autocompletions given

Expected behavior

Correctly complete autocompletion of partial flags

Additional context

I worked around this by using a bash wrapper around the command binary, which rewrites calls in this form command --XXX --generate-shell-completion to command - --generate-shell-completion, which seems to work for bash/zsh.
Even though the command returns all possible flags, it's completion suggestions are filtered to relevant completions only.

Want to fix this yourself?

We'd love to have more contributors on this project! If the fix for
this bug is easily explained and very small, feel free to create a
pull request for it.

Run go version and paste its output here

go version go1.25.3 darwin/arm64

Run go env and paste its output here

Rather not, but available upon requests. Very simple default goenv setup. Go version 1.24.4

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