Hi,
Trying to set a local boolean flag 'prompt', but the value is not set,
for the local integer flag 'times' the value is set.
What I am doing wrong ?
````
package cmd
import (
"github.com/spf13/cobra"
"fmt"
)
var myCommand = &cobra.Command{
Use: "new 'application'",
Short: "Create something new",
Long: "",
Run : runmyCommand,
}
var prompt bool
var times int
func init() {
myCommand.Flags().BoolVarP(&prompt, "prompt", "p", true, "Prompt user")
myCommand.Flags().IntVarP(×, "times", "t", 1, "test local flag")
RootCmd.AddCommand(myCommand)
}
func runmyCommand(cmd *cobra.Command, args []string) {
fmt.Printf("value of prompt %v (is always true)\n",prompt)
fmt.Printf("value of times %v\n",times)
}
````
Hello. If you don't provide flag from CLI, it will always be set to default value.
User should explicitly provide false value to this flag to set it false, i.e. `--prompt=false', otherwise it will be always true.
I understand, that was not clear from the README, for flags taking integers I can specify
'--times 2' instead of '--times=2'
Most helpful comment
I understand, that was not clear from the README, for flags taking integers I can specify
'--times 2' instead of '--times=2'