42 lines
803 B
Go
42 lines
803 B
Go
package cmd
|
|
|
|
import "go.fifitido.net/cmd/flags"
|
|
|
|
type Option func(*Command)
|
|
|
|
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...)
|
|
}
|
|
}
|