-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shell Completions #2425
Comments
I'm in general agreement with you here - I think the proper way forward for any completion system is a shell-specific, grammar-aware script that's generated from your CLI that embraces the static portions of your grammar in a shell-specific way, while allowing your app to supply dynamic completions when required. Shell-by-shell the balance of what can be put in the script vs needing the dynamic invocation would be tweaked. This is the pattern you see in so many other libraries, and it's that way for a reason! |
I've just caught up on the last community standup and was interested to hear the direction for completions, and wanted to share how I'm solving this today.
First off, I love the idea of the automagic self-describing directives based completions today (dotnet-suggest), however as was mentioned this is slow (although very workable when AOTing). I abandoned this approach in the end mostly because:
So what I do for my internal tool (can't share the code sorry) is have a separate file that has the grammar of the command line in, and using a tool (complgen) to produce the per-shell scripts. I have the outputs of these then embedded my tool, so I can say
jaz completions fish
(the tool is named jaz) and it will output thefish
shell snipped. This plays well with eco-system tools like homebrew (example).Here is what my usage grammar looks like:
You can see this supports calling back into itself for completions (see
<CREDENTIALS-PROFILE>
), this is awesome because I get nice completions across all shells, and it's fast because it's static, but I get the dynamic behaviours when I want them.I'm not suggesting that this exact tool/grammar be selected as the approach, but as a general pattern I think this is really powerful yet simple for developers.
The text was updated successfully, but these errors were encountered: