Replies: 1 comment
-
Hi @hverlin , thx for your detailed feature request! Some thoughts:
Instead of passing
I think i would use options instead of arguments.
I don't think I quite understand what you mean by "return them as additional arguments". Can you show me an example of what that would look like? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Thank you for this library!
Some questions about auto-completion.
Send additional context to
complete()
functionCurrently, the
complete
has no context apart from the option/argument that it is completing.complete()
does not take any arguments.Would it be feasible in your opinion to send the full command (maybe as is) to the
complete()
function?Here is an example of what I would like to achieve
I can auto-complete
<program>
dynamically (e.g., by reading the content of some configuration listing all possible programs).However, then I am not able to auto-complete
<some_args>
as I would need to know the name of the program.For now, the workaround seems to be that one has to register all possible combinations dynamically in advance. Due to the fact that some the command name gets converted to shell functions, it's not possible to use
:
or other special characters (whereas it's possible when usingcomplete
)I think one way to implement this could be to update
https://github.com/c4spar/deno-cliffy/blob/main/command/completions/_zsh_completions_generator.ts#L50-58
with
Auto-completion for variadic arguments
Another question is how do I get auto-completion working for variadic arguments?
If I use the following, it appears that this will only auto-complete once instead of several times?
For
zsh
, one way to achieve I believe is to replacewith
here: https://github.com/c4spar/deno-cliffy/blob/main/command/completions/_zsh_completions_generator.ts#L173
https://zsh.sourceforge.io/Doc/Release/Completion-System.html#:~:text=%3A*pattern%3Amessage%3Aaction
Description for arguments
Currently, the
complete()
function returns an array of possible arguments. Do you think it would be possible to return them as additional arguments?zsh
at least seems to support this:https://zsh.sourceforge.io/Doc/Release/Completion-Widgets.html#Completion-Widgets:~:text=This%20adds%20per%2Dcompletion%20display%20strings
This could then automatically create a new
${action}_description
function which would return the corresponding list of descriptions.https://github.com/c4spar/deno-cliffy/blob/main/command/completions/_zsh_completions_generator.ts#L55
zsh
also supports using-l
to put the autocompletion in lines instead of columns, as well as-X 'top-level description'
to print a description at the topcompadd -X 'my explanation' -l -d _descriptions_values -a values
I am happy to contribute if this is of interest to you.
Beta Was this translation helpful? Give feedback.
All reactions