github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/prompts/internal/bool.go (about) 1 package main 2 3 import ( 4 "github.com/pterm/pterm" 5 "github.com/taubyte/tau-cli/flags" 6 "github.com/taubyte/tau-cli/prompts" 7 "github.com/urfave/cli/v2" 8 ) 9 10 var testBoolFlag = &flags.BoolWithInverseFlag{ 11 BoolFlag: &cli.BoolFlag{ 12 Name: "bool", 13 }, 14 } 15 16 var BoolCommand = &cli.Command{ 17 Name: "bool", 18 Flags: []cli.Flag{ 19 testBoolFlag, 20 }, 21 Action: func(ctx *cli.Context) error { 22 23 // New 24 value := prompts.GetOrAskForBool(ctx, testBoolFlag.Name, "Provide a boolean:") 25 26 // Edit, sending empty cli context so that the flags are not set 27 value = prompts.GetOrAskForBool(&cli.Context{}, testBoolFlag.Name, "Provide a boolean:", value) 28 29 pterm.Success.Printfln("Got bool: `%v`", value) 30 return nil 31 }, 32 }