Skip to content

Implement shell completion#1650

Merged
onsi merged 1 commit intoonsi:masterfrom
koct9i:add-shell-completion
Apr 6, 2026
Merged

Implement shell completion#1650
onsi merged 1 commit intoonsi:masterfrom
koct9i:add-shell-completion

Conversation

@koct9i
Copy link
Copy Markdown
Contributor

@koct9i koct9i commented Apr 4, 2026

This adds subcommand "completion" to the CLI which:

  • generates completion script: ginkgo completion bash
  • installs completion script: ginkgo completion --install bash
  • generates commands completion: ginkgo completion --complete bash --
  • generates flags completion: ginkgo completion --complete bash -- run --
  • without suggests script fails back to default and completes file paths

For "bash" use hack similar to used in cobra, but implement it in go:

  • single suggests are issued as is without description
  • multiple suggests are issued in form "{suggest}{align}({description})" I.e. description is a part of suggest but shell will use only common prefix.

For "zsh" issue completion response in form "{suggest}:{description}".

For "fish" issue completion response in form "{suggest}\t{description}".

This adds subcommand "completion" to the CLI which:
- generates completion script: ginkgo completion bash
- installs completion script: ginkgo completion --install bash
- generates commands completion: ginkgo completion --complete bash --
- generates flags completion: ginkgo completion --complete bash -- run --
- without suggests script fails back to default and completes file paths

For "bash" use hack similar to used in cobra, but implement it in go:
- single suggests are issued as is without description
- multiple suggests are issued in form "{suggest}{align}({description})"
I.e. description is a part of suggest but shell will use only common prefix.

For "zsh" issue completion response in form "{suggest}:{description}".

For "fish" issue completion response in form "{suggest}\t{description}".

Signed-off-by: Konstantin Khlebnikov <[email protected]>
@onsi
Copy link
Copy Markdown
Owner

onsi commented Apr 6, 2026

cool, thanks!

@onsi onsi merged commit 94151c8 into onsi:master Apr 6, 2026
6 of 9 checks passed
@koct9i koct9i deleted the add-shell-completion branch April 7, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants