0

I created a Cobra CLI application, and after releasing it with Go releaser. What I am trying to do is be able to download it and then have it be able to run locally from the binary. So what I would like is to do is:

  1. click the binary
  2. install it locally
  3. enter my terminal
  4. enter $ my-cli <SOME_COMMAND> -<SOME_FLAG> and run the project accordingly

I've been trying to find the appropriate docs for how to do something like this. What happens now is I try to open it, then the application runs the rootCmd.Execute() and then the terminal tab closes abruptly.

is there some resource that I could read that talks about this?

kostix
  • 51,517
  • 14
  • 93
  • 176
Ctfrancia
  • 1,248
  • 1
  • 15
  • 39
  • This question has nothing to do with Go. What you're after, is basically a standalone topic which deals with installing software into the user's system. There are multiple approaches to do so; they wastly differ from platform to platform, and you did not even mention which platform you're after. Unfortunately, even if you were to ask a proper narrowly-scoped question about this, it would still be off-topic for SO because it cannot have a simple spot-on answer. – kostix Apr 29 '22 at 12:23
  • From «I try to open it, then the application runs <…> and then the terminal tab closes abruptly» I guess you're running Windows. – kostix Apr 29 '22 at 12:26
  • If you're after the most simplistic approach to installation possible I'd recommend to just not mess with automating the installation and use what old farts like me call ["XCOPY deployment"](https://en.wikipedia.org/wiki/XCOPY#XCOPY_deployment)—that is, just ask the user to manually drop your binary to a directory which is listed in their `PATH` environment variable. If you have no idea what that variable means, it's the time to learn about this because that's what allows running commands in a console window without typin their full pathnames. – kostix Apr 29 '22 at 12:29
  • Ok, so this is a non-go question and will look elsewhere for an answer. Thank you. Also I am running this on MacOS but I have a friend that will run this CLI on Windows. Since the GoReleaser provides the binaries then I am looking for a way to create these bindings. thanks! – Ctfrancia Apr 29 '22 at 12:30
  • 1
    Note that GoReleaser has [discussions enabled in their Github project](https://github.com/goreleaser/goreleaser/discussions), so you might just ask there (having had searched for relevant past discussions first). – kostix Apr 29 '22 at 13:26

0 Answers0