github.com/study-group-99/pilates@v0.2.2/root.go (about) 1 package pilates 2 3 import ( 4 "fmt" 5 6 "github.com/bh90210/clir" 7 ) 8 9 func RootCommand(cli *clir.Cli) { 10 cli.LongDescription("pilates is an educational devops tool designed to help you along you curriculum.") 11 var version bool 12 cli.BoolFlag("version", "v", "Pilates CLI version.", &version) 13 var update bool 14 cli.BoolFlag("update", "u", "Update Pilates to the latest version.", &update) 15 cli.Action(func() error { 16 switch { 17 case version && update: 18 return fmt.Errorf("select only one option. Either -u, --update or -v, --version") 19 case version: 20 fmt.Println(cli.Name(), "version", cli.Version()) 21 return nil 22 case update: 23 return fmt.Errorf("WIP. We need your help implementing the update function! go to https://github.com/study-group-99/pilates/discussions for more information.") 24 } 25 26 w := cli.OtherArgs() 27 if len(w) == 0 { 28 cli.PrintHelp() 29 return nil 30 } 31 return fmt.Errorf(`error: unknown command %#q for %#q 32 Run '%[2]s --help' for usage`, w[0], cli.Name()) 33 }) 34 }