// List is a `Command`.
type List {
Pattern string `descr:"pattern to match"` // filled with the value for -pattern
Kind cli.Enum `descr:"kind to select" enum:"kind1 kind2"` // space separated enum values (default is the first one)
hidden bool // non exported fields are ignored
}
func (l List) Name() string {
return "list"
}
func (l List) Description() string {
return "list files for the given pattern"
}
func (l List) Run(args []string) error {
files := []string{"foo", "bar"}
for _, file := range files {
if strings.Contain(file, l.Pattern) {
fmt.Println(file)
}
}
return nil
}
cli.Run("mycli", "a cli example", &List{})