github.com/abhinav/git-pr@v0.6.1-0.20171029234004-54218d68c11b/cli/option.go (about) 1 package cli 2 3 import "github.com/jessevdk/go-flags" 4 5 // Option configures the behavior of Main. 6 type Option interface { 7 apply(*mainConfig) 8 } 9 10 // ShortDesc is an Option that specifies a short description of the program. 11 type ShortDesc string 12 13 func (s ShortDesc) apply(c *mainConfig) { 14 c.ShortDesc = string(s) 15 } 16 17 // Command is an option that adds a subcommand to the program. 18 type Command struct { 19 Name string 20 ShortDesc string 21 Build func(ConfigBuilder) flags.Commander 22 } 23 24 func (cmd *Command) apply(c *mainConfig) { 25 c.Commands = append(c.Commands, cmd) 26 }