Skip to content

feat: shell completion value hints + docs (bash/zsh)#5040

Open
0xDevNinja wants to merge 2 commits into
trufflesecurity:mainfrom
0xDevNinja:feat/shell-completion
Open

feat: shell completion value hints + docs (bash/zsh)#5040
0xDevNinja wants to merge 2 commits into
trufflesecurity:mainfrom
0xDevNinja:feat/shell-completion

Conversation

@0xDevNinja

@0xDevNinja 0xDevNinja commented Jun 16, 2026

Copy link
Copy Markdown

Description:

Closes #4923.

trufflehog is built on kingpin/v2, which already auto-registers hidden --completion-script-bash and --completion-script-zsh flags, so subcommand and flag-name completion already worked — it was just undocumented, and flags with a fixed set of values gave no value suggestions (the --results example called out in the issue).

This PR:

  • Adds HintOptions to the flags that accept a fixed set of values, so tab-completion suggests them:

    • --resultsverified, unverified, unknown, filtered_unverified
    • --protocol (syslog) → udp, tcp
    • --format (syslog) → rfc3164, rfc5424

    Parsing is unchanged; only completion hints are added.

  • Documents how to generate/install the bash and zsh completion scripts in the README.

Verified locally:

$ trufflehog --completion-bash --results
verified
unverified
unknown
filtered_unverified

go build, go vet, and gofmt -l are clean.

Checklist:

  • Tests passing (go build / go vet / gofmt clean; no test files in the affected package). make test-community unaffected.
  • Lint passing — golangci-lint not installed in my environment; go vet and gofmt are clean.

Note

Low Risk
Documentation and completion-metadata only; no changes to scan logic or flag parsing behavior.

Overview
Improves tab completion for flags with fixed choices by adding kingpin HintOptions on --results (verified, unverified, unknown, filtered_unverified) and on syslog --protocol / --format. Flag parsing and validation are unchanged; only completion suggestions are new.

Adds a README section on generating and installing bash and zsh completion scripts via the existing --completion-script-bash / --completion-script-zsh flags.

Reviewed by Cursor Bugbot for commit fed2898. Bugbot is set up for automated code reviews on this repo. Configure here.

Register HintOptions on flags that accept a fixed set of values so that
bash/zsh tab-completion suggests them:

  --results   verified, unverified, unknown, filtered_unverified
  --protocol  udp, tcp (syslog)
  --format    rfc3164, rfc5424 (syslog)

The hints are surfaced through kingpin's built-in --completion-bash
mechanism without changing flag parsing.

Refs trufflesecurity#4923
Add a Shell completion section explaining how to generate and install the
bash and zsh completion scripts via --completion-script-bash and
--completion-script-zsh.

Refs trufflesecurity#4923
@0xDevNinja 0xDevNinja requested a review from a team June 16, 2026 07:18
@0xDevNinja 0xDevNinja requested a review from a team as a code owner June 16, 2026 07:18
@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Zsh/Bash Completion

2 participants