Closed benbenbang closed 7 months ago
Hi @benbenbang.
I think that's a great idea. I have been struggling with auto completion. Please take a look at this branch (and feel free to make adjustments, or to submit your own PR):
The problem I am having is that once I add 1 command (completion), chatgpt no longer works as intended:
2024-02-20 09:12:21 ⌚ Guillermos-MacBook-Pro in ~/workspace/chatgpt-cli
± |main {4} U:1 ✗| → ./bin/chatgpt what is the capital of denmark
unknown command "what" for "chatgpt"
2024-02-20 09:12:52 ⌚ Guillermos-MacBook-Pro in ~/workspace/chatgpt-cli
± |main {4} U:1 ✗| → chatgpt what is the capital of denmark
The capital of Denmark is Copenhagen (Danish: København).
I love Cobra/Viper but also really like to use the CLI without commands :) -- what would be a good workaround for this?
Hello @kardolus,
Sure, let me take a look tmw morning
If we can't get the command to work I suppose we could always set up a script ourselves.
Here's a completion script just for flag completion: https://github.com/kardolus/chatgpt-cli/blob/completion-script/scripts/completion.sh -- not sure if it works across different shells though. I can confirm it works on GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)
.
Merged it into the main
branch: https://github.com/kardolus/chatgpt-cli?tab=readme-ov-file#command-line-autocompletion
I am open to suggestions for something better though :).
Long day :D Anyways, we can make it simple or make it "complex" Maybe I am wrong, or say there's no one way to do it. But I can see from the current implementation that you are trying to circuit the command by flags. Hence, the command is not that "official" structure.
I have a proposal, but it might become a project instead of an issue 😅
the idea is mainly to
prompt
, for example, as a subcommandprompt
prompt
prompt
and the grouping can be something like
$ chatgpt
chatgpt-cli is a cli to...
some other desc
Enjoy! :)
Chat
prompt Run prompt command
Settings Commands
completion Generate completion script
confg Run config settings command
Other Commands:
update Update your chatgpt-cli version
version Check your chatgpt-cli version
Use "chatgpt <command> --help" for more information about a given command.
like so
And for the config
subcommand, I am thinking we can extend it to
And so on.
I'd like to stop here first to hear your feedback. Otherwise, I still have some idea can be implemented 😆
Thanks @benbenbang! I think the way you are describing the use of cobra/viper makes total sense. However, I really like the current UX (having the simplicity of chatgpt <message>
without a command). Maybe the current flag completion script is the way to go for now? It's not perfect but it works. I have been enjoying flag completion since yesterday :). Great idea! Thank you.
Alright, nvm, then.
I will create a PR and keep it as it is, and just add a flag to generate a completion script
If you don't mind, I can create another PR to add a makefile
to run the test / build the binaries?
Thanks @benbenbang! I think the way you are describing the use of cobra/viper makes total sense. However, I really like the current UX (having the simplicity of
chatgpt <message>
without a command). Maybe the current flag completion script is the way to go for now? It's not perfect but it works. I have been enjoying flag completion since yesterday :). Great idea! Thank you.
My suggestion won't change how you prompt since the default command is the only prompt
command. It will be triggered when encountering execute error or use chatgpt prompt xxx
Thank you! This is great. I like Makefiles, so that sounds good to me. Looking at your PR.
Hi there,
Since we are using
cobra
, any plan to use the completion to help with the flags? I can do a PR if it's ok for you :)Thanks