dynlay
This commit is contained in:
@ -1,53 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/apply"
|
||||
"novit.nc/direktil/pkg/config"
|
||||
dlog "novit.nc/direktil/pkg/log"
|
||||
)
|
||||
|
||||
var (
|
||||
log = dlog.Get("dkl-apply-config")
|
||||
)
|
||||
|
||||
func main() {
|
||||
configPath := flag.String("config", "config.yaml", "config to load (\"-\" for stdin)")
|
||||
doFiles := flag.Bool("files", false, "apply files")
|
||||
filesFilters := flag.String("files-filters", "", "comma-separated filters to select files to apply")
|
||||
flag.Parse()
|
||||
|
||||
log.SetConsole(os.Stderr)
|
||||
|
||||
var (
|
||||
cfg *config.Config
|
||||
err error
|
||||
)
|
||||
|
||||
if *configPath == "-" {
|
||||
log.Print("loading config from stdin")
|
||||
cfg, err = config.Read(os.Stdin)
|
||||
|
||||
} else {
|
||||
log.Print("loading config from ", *configPath)
|
||||
cfg, err = config.Load(*configPath)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Print("failed to load config: ", err)
|
||||
}
|
||||
|
||||
if *doFiles {
|
||||
filters := []string{}
|
||||
if *filesFilters != "" {
|
||||
filters = strings.Split(*filesFilters, ",")
|
||||
}
|
||||
if err = apply.Files(cfg /*log,*/, filters...); err != nil {
|
||||
log.Taint(dlog.Fatal, "failed to apply files: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"novit.nc/direktil/inits/pkg/cmd/applyconfig"
|
||||
cmddynlay "novit.nc/direktil/inits/pkg/cmd/dynlay"
|
||||
cmdinit "novit.nc/direktil/inits/pkg/cmd/init"
|
||||
)
|
||||
@ -14,6 +15,7 @@ func main() {
|
||||
|
||||
root.AddCommand(cmdinit.Command())
|
||||
root.AddCommand(cmddynlay.Command())
|
||||
root.AddCommand(applyconfig.Command())
|
||||
|
||||
if err := root.Execute(); err != nil {
|
||||
log.Fatal("error: ", err)
|
||||
|
Reference in New Issue
Block a user