Open y-marui opened 2 years ago
Hi @sublee
I just came across this one in my attempt to implement auto-completion for simonw/llm (in simonw/llm#261). The proposed fix does work in that case as well.
Can I add anything to this pull request to get it merged? E.g. test coverage?
In the case of the LLM tool I observed the following. Without the fix, no completion is output:
$ env COMP_WORDS="llm" COMP_CWORD=1 _LLM_COMPLETE=bash_complete llm
(no_output)
Once I apply the fix, it works:
$ env COMP_WORDS="llm" COMP_CWORD=1 _LLM_COMPLETE=bash_complete llm
plain,aliases
plain,chat
plain,collections
plain,embed
plain,embed-models
plain,embed-multi
plain,install
plain,keys
plain,logs
plain,models
plain,openai
plain,plugins
plain,prompt
plain,similar
plain,templates
plain,uninstall
If
_{prog_name}_COMPLETE
is set, the click will execute completion instead of normal flow. On completion, adding the default command name to arg cause trouble.