Skip to content

enhancement(cli): Shell autocomplete for the Vector CLI#9823

Closed
lucperkins wants to merge 5 commits intomasterfrom
cli-autocomplete
Closed

enhancement(cli): Shell autocomplete for the Vector CLI#9823
lucperkins wants to merge 5 commits intomasterfrom
cli-autocomplete

Conversation

@lucperkins
Copy link
Contributor

@lucperkins lucperkins commented Oct 28, 2021

This is currently a draft, as I found out after submitting that attempting to generate zsh completions throws a fatal panic due to an issue in clap. This has been fixed in clap (see this PR). Those changes have not, however, made it into a non-beta release and thus haven't been yet incorporated into structopt. Once structopt has incorporated those changes, we should be able to push this through without issue; until then, a panic on vector completion zsh is likely to surprise and frustrate users, so let's keep this on ice for the time being.

Luc Perkins added 4 commits October 28, 2021 08:18
Signed-off-by: Luc Perkins <luc.perkins@datadoghq.com>
Signed-off-by: Luc Perkins <luc.perkins@datadoghq.com>
Signed-off-by: Luc Perkins <luc.perkins@datadoghq.com>
Signed-off-by: Luc Perkins <luc.perkins@datadoghq.com>
@netlify
Copy link

netlify bot commented Oct 28, 2021

✔️ Deploy Preview for vector-project canceled.

🔨 Explore the source changes: a9a2cd2

🔍 Inspect the deploy log: https://app.netlify.com/sites/vector-project/deploys/617ad2c05d367f00088b88a5

@lucperkins lucperkins marked this pull request as draft October 28, 2021 16:30
Signed-off-by: Luc Perkins <luc.perkins@datadoghq.com>
@hhromic
Copy link
Contributor

hhromic commented Oct 28, 2021

I was just using the VRL shell to file a bug report and was getting so mad of not having TAB-autocompletion, specially when auto-completion is already possible by using the RightArrow key instead of TAB. Thanks so much for this!

EDIT: Wait, the RightArrow key is not actually autocompletion... so thanks even more for this!

@lucperkins
Copy link
Contributor Author

@hhromic Sadly, I pushed this having only tested Bash and Fish, which worked great, but now I see that Zsh panics with a completely inscrutable error. Sigh. I'll see what I can do, but if this requires an overhaul of our CLI plumbing this may not come through for a while.

@hhromic
Copy link
Contributor

hhromic commented Oct 28, 2021

@lucperkins apologies, I just realised I completely misunderstood this PR 🤦

You are implementing autocompletion for the vector command itself for the user shell!
I thought you were implemeting autocompletion for the VRL shell itself, i.e. inside vector vrl.

For example this sort of thing:

$ parse_ [tab]
parse_apache_log  parse_key_value  parse_syslog ...

$ parse_key_value(message, key [tab]
key_value_delimiter

$ parse_key_value(message, key_value_delimiter: ",", accept_ [tab]
accept_standalone_key

(that last one I never remember the exact name so I often have to go look it up in the docs!)

@lucperkins
Copy link
Contributor Author

lucperkins commented Oct 28, 2021

@hhromic Ah yes, this is just for the CLI. Inside the VRL REPL there is only limited completion. I may take a stab at that at some point but I can't say it's high priority at the moment. In the meantime, if you're writing VRL in separate .vrl files there is a VS Code extension that offers tab completion for function names.

I should also note that in the VRL REPL there are some helper commands that you can see if you run help. help functions (or help funcs or help fs) displays a list of all available functions. To open up the docs for a specific function in your browser you can run help docs <function>, e.g. help docs parse_json. I know that doesn't match 1:1 with what you're seeking but I've personally found it pretty useful to remember names like parse_aws_cloudwatch_log_subscription_message.

@lucperkins
Copy link
Contributor Author

Closing this for now, as it's unclear when the necessary dependency updates will happen. But I'll keep checking back on that and reopen this when the time comes.

@lucperkins lucperkins closed this Nov 2, 2021
weriomat added a commit to weriomat/vector that referenced this pull request Dec 26, 2025
This adds support for generating autocompletion for different shells for
the vector cli.
Superseds [vectordotdev#9823](vectordotdev#9823)
github-merge-queue bot pushed a commit that referenced this pull request Jan 15, 2026
* enhancement(cli): Shell autocompletion for vector cli

This adds support for generating autocompletion for different shells for
the vector cli.
Superseds [#9823](#9823)

* chore: add changelog

* Bump versions

* Update changelog

* vdev build licenses

---------

Co-authored-by: Thomas <thomas.schneider@datadoghq.com>
thomasqueirozb added a commit that referenced this pull request Jan 21, 2026
* enhancement(cli): Shell autocompletion for vector cli

This adds support for generating autocompletion for different shells for
the vector cli.
Superseds [#9823](#9823)

* chore: add changelog

* Bump versions

* Update changelog

* vdev build licenses

---------

Co-authored-by: Thomas <thomas.schneider@datadoghq.com>
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