Questions tagged [go-cobra]

A Commander for modern Go CLI interactions

A Commander for modern Go CLI interactions (https://github.com/spf13/cobra)

125 questions
-1
votes
0 answers

What is a Common Pattern for CLI Args vs Environment Vars vs defaults in go?

I would like to define a tool which provides a CLI Interface to set parameters when run locally but can also just use environment variables to set the needed parameters. Lastly there should be sane defaults set for most (not all) parameters. The…
-1
votes
1 answer

How to provide go bin with commands

I use the following code to create command which should run according to some flags that are passed from the cli. I use the cobra repo https://github.com/spf13/cobra when I run it with go run main.go echo test I get Print: test which works. Now I…
07_05_GuyT
  • 2,787
  • 14
  • 43
  • 88
-2
votes
1 answer

Failed to get flag value

I created a small Go application with the https://github.com/spf13/cobra library. I created a new flag, -t or --token, and when I pass this argument I want the application to print it. This is what I did: func init() { fmt.Println("[*]…
E235
  • 11,560
  • 24
  • 91
  • 141
-2
votes
2 answers

Cache or Persist a value even if process ends

Writing a CLI application in GoLang and want to use URL across different sessions/commands. Implementing CLI through Cobra where I want to configure URL at the beginning and then keep using it across other commands. Tried to use below approach…
rai.skumar
  • 10,309
  • 6
  • 39
  • 55
-4
votes
1 answer

How can I get the Flag chosen by the user in my CLI

I have specified some flags like you can see below: deleteCmd.Flags().StringVarP(&option, "wallet", "w", "", "Specify the wallet to be deleted") deleteCmd.Flags().StringVarP(&option, "holding", "o", "", "Specify the holding to be…
1 2 3
8
9