package cmd import "go.fifitido.net/cmd/flags" type Option func(*Command) func WithShortDescription(s string) Option { return func(c *Command) { c.ShortDescription = s } } func WithLongDescription(s string) Option { return func(c *Command) { c.LongDescription = s } } func WithArgument(name string, required bool) Option { return func(c *Command) { c.Arguments = append(c.Arguments, &Argument{name, required}) } } func WithArguments(args []*Argument) Option { return func(c *Command) { c.Arguments = append(c.Arguments, args...) } } func WithFlag(f flags.Flag) Option { return func(c *Command) { c.Flags = append(c.Flags, f) } } func WithFlags(fs []flags.Flag) Option { return func(c *Command) { c.Flags = append(c.Flags, fs...) } } func WithSubcommand(s *Command) Option { return func(c *Command) { c.Subcommands = append(c.Subcommands, s) } } func WithSubcommands(ss []*Command) Option { return func(c *Command) { c.Subcommands = append(c.Subcommands, ss...) } } func WithRunFunc(r RunFunc) Option { return func(c *Command) { c.Run = r } } func WithRunErrFunc(r RunErrFunc) Option { return func(c *Command) { c.RunE = r } }