Reputation: 319
I created a Go CLI app with the cobra framework via the cobra add
command. After building it with go build
it works totally fine if I'm in the repository in the windows cmd. If I click on the .exe
I get the following message on a terminal:
This is a command line tool.
You need to open cmd.exe and run it from there.
This is not suitable for my case. I'd like to have a console applocation like in C or C++ which opens directly and you can type in commands there. Do you have any suggestions how I could realize this while using cobra?
Thank you a lot in advance.
Upvotes: 3
Views: 886
Reputation: 1571
This is done on purpose as no arguments will be provided to the command when started through explorer.exe, as the main purpose of using cobra is for parsing arguments and stuff.
To disable this feature.
Add this line in your init()
func init(){
cobra.MousetrapHelpText = ""
}
This let's your program run, and it exits immediately, to see if it's working fine.
Use time.Sleep()
, so that you can see the output.
Upvotes: 2