bah alors, et les filtres?

This commit is contained in:
Mikaël Cluseau 2023-02-01 18:51:44 +01:00
parent e9ba7987b8
commit 9fe316ad44

View File

@ -1,9 +1,7 @@
package applyconfig package applyconfig
import ( import (
"flag"
"os" "os"
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"novit.nc/direktil/inits/pkg/apply" "novit.nc/direktil/inits/pkg/apply"
@ -13,7 +11,7 @@ import (
) )
var ( var (
filesFilters string filters []string
log = dlog.Get("dkl") log = dlog.Get("dkl")
) )
@ -26,7 +24,8 @@ func Command() (c *cobra.Command) {
Run: run, Run: run,
} }
flag.StringVar(&filesFilters, "files-filters", "", "comma-separated filters to select files to apply") flag := c.Flags()
flag.StringArrayVarP(&filters, "filter", "F", []string{}, "glob filter to select files to apply")
return c return c
} }
@ -52,10 +51,6 @@ func run(_ *cobra.Command, args []string) {
log.Print("failed to load config: ", err) log.Print("failed to load config: ", err)
} }
filters := []string{}
if filesFilters != "" {
filters = strings.Split(filesFilters, ",")
}
if err = apply.Files(cfg /*log,*/, filters...); err != nil { if err = apply.Files(cfg /*log,*/, filters...); err != nil {
log.Taint(dlog.Fatal, "failed to apply files: ", err) log.Taint(dlog.Fatal, "failed to apply files: ", err)
os.Exit(1) os.Exit(1)