-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat(zsh): support support space-separated completion #406
Conversation
${this.genZshFlagArgumentsBlock(this.commands.find(c => c.id === id)?.flags)} | ||
} | ||
|
||
local context state state_descr line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't link to zsh docs so I'll leave chunks related to the code that are searchable here:
https://zsh.sourceforge.io/Doc/Release/Completion-System.html
A function calling _arguments with at least one action containing a ‘->string’ must therefore declare appropriate local parameters:
case $line[1] in | ||
%s | ||
*) | ||
_${compFuncName}_flags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sf data query --json -<tab>
line[1]
is the last word on the current line, if it matches any valid command of the cotopic it will suggest flags valid to that command.
*)
is the "default" block of the switch statement, if line[1]
doesn't match any valid command of the cotopic then keep suggesting flags of the cotopic.
it's possible on zsh but not sure about bash/powershell, logged this WI to check once powershell comp is finished. I'll keep an eye on user feedback too.
✅ fixed.
I haven't found a way to do this with the current zsh comp utilities. but yep, unless users already knows it is a command they may skip it.
zsh has comp utilities for this, see
✅ fixed. |
@mshanemc major bump intentional, make sure to squash merge the PR and mark it as a breaking change (I think GHA does this? or is the pjson bump enough?). |
QA Notes ✅ after running the ✅ --help is in the flags list ✅ ran
|
This PR adds support for space-separated commands.
See this blog for how state is kept between comp function calls:
https://www.dolthub.com/blog/2021-11-15-zsh-completions-with-subcommands/
zsh completion docs: https://zsh.sourceforge.io/Doc/Release/Completion-System.html
see also this guide: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#intro
NEW
options
set (https://github.com/salesforcecli/plugin-data/blob/355f2a846cf6fea17614417afbea44c51ca0ade4/src/commands/data/query.ts#L80)-
is present on the current line(<command> -<tab>
).multiple
prop set to true will be suggested even if it's already present on the current line (https://github.com/salesforcecli/plugin-deploy-retrieve/blob/c09b83a48f763df053a6209e84648aafc5419709/src/commands/deploy/metadata.ts#L80)cotopics
A cotopic is an id that is both a command and a topic, a few examples from the
sf
cli:data query
->data query resume
deploy
->deploy functions|metadata
logout
->logout functions|org
When a cotopic is present on the current line and you press
tab
, it will suggest the next valid topics/commands:sf deploy <tab>
⬇️but if a
-
is present after the cotopic pressing tab will suggest flags only valid to it:sf data query -<tab>
🔽@W-12069114@
Release notes
BREAKING CHANGE
plugin-autocomplete
will default to the autocomplete for the space separator if the CLI supports it.If you still want to use the autocomplet for colon-separated commands you can set the
OCLIF_AUTOCOMPLETE_TOPIC_SEPARATOR
env var tocolon
.https://github.com/oclif/plugin-autocomplete/#topic-separator
Features
New zsh autocomplete for oclif CLIs using space as a topic separator.
This implementation includes the following new features:
multiple: true
set will be suggested in autocompletion even if it's already been used.-
is present on the current line