Closed benbenbang closed 4 months ago
Thank you! This is great :).
The script that is being generated doesn't work for me for some reason. I may as well be misunderstanding the usage though. Here's my output:
2024-02-22 17:27:57 ⌚ Guillermos-MacBook-Pro in ~/workspace/tmp/chatgpt-cli
± |feat/implement_autocompletion ✓| → . <(./bin/chatgpt --set-completions bash)
-bash: complete: --: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
Thank you! This is great :).
The script that is being generated doesn't work for me for some reason. I may as well be misunderstanding the usage though. Here's my output:
2024-02-22 17:27:57 ⌚ Guillermos-MacBook-Pro in ~/workspace/tmp/chatgpt-cli ± |feat/implement_autocompletion ✓| → . <(./bin/chatgpt --set-completions bash) -bash: complete: --: invalid option complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
Ah thanks, I should have seen this from the output above 🤦🏻♂️
The reason is due to #compdef --set-completions
instead of chatgpt
I tested the new version. Now, it should work perfectly
Fixed output:
╰─➤ chatgpt --set-completions zsh
#compdef chatgpt
compdef _chatgpt chatgpt
# zsh completion for chatgpt -*- shell-script -*-
__chatgpt_debug()
{
...
}
_chatgpt()
{
...
}
# don't run the completion function when being source-ed or eval-ed
if [ "$funcstack[1]" = "_chatgpt" ]; then
_chatgpt
fi
Also, make the Usage
clearer
╰─➤ chatgpt --set-completions abc
Usage:
chatgpt --set-completions [bash|zsh|fish|powershell]
Flags:
-h, --help help for --set-completions
Invalid Arg: abc
Very cool! Thank you!!
Add a simple logic to generate a completion script.
The following is the "proof"
resolve #26
ChatGpt prompt:
Set completion flag without input:
Set completion flag with invalid arg
Set completion flag with
-h
or--help
Set completion flag with
zsh
, for example: