feat: shell completion value hints + docs (bash/zsh)#5040
Open
0xDevNinja wants to merge 2 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Closes #4923.
trufflehogis built onkingpin/v2, which already auto-registers hidden--completion-script-bashand--completion-script-zshflags, 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--resultsexample called out in the issue).This PR:
Adds
HintOptionsto the flags that accept a fixed set of values, so tab-completion suggests them:--results→verified,unverified,unknown,filtered_unverified--protocol(syslog) →udp,tcp--format(syslog) →rfc3164,rfc5424Parsing is unchanged; only completion hints are added.
Documents how to generate/install the bash and zsh completion scripts in the README.
Verified locally:
go build,go vet, andgofmt -lare clean.Checklist:
go build/go vet/gofmtclean; no test files in the affected package).make test-communityunaffected.golangci-lintnot installed in my environment;go vetandgofmtare 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
HintOptionson--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-zshflags.Reviewed by Cursor Bugbot for commit fed2898. Bugbot is set up for automated code reviews on this repo. Configure here.