diff --git a/cmd/graphplan/main.go b/cmd/graphplan/main.go index 3b8843e..56b93f8 100644 --- a/cmd/graphplan/main.go +++ b/cmd/graphplan/main.go @@ -1,16 +1,18 @@ package graphplan import ( - "log" "path/filepath" "github.com/bmeg/sifter/graphplan" + "github.com/bmeg/sifter/logger" "github.com/bmeg/sifter/playbook" "github.com/spf13/cobra" ) var outScriptDir = "" var outDataDir = "./" +var objectExclude = []string{} +var verbose bool = false // Cmd is the declaration of the command line var Cmd = &cobra.Command{ @@ -19,6 +21,10 @@ var Cmd = &cobra.Command{ Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { + if verbose { + logger.Init(true, false) + } + scriptPath, _ := filepath.Abs(args[0]) /* @@ -40,10 +46,10 @@ var Cmd = &cobra.Command{ if sifterErr := playbook.ParseFile(scriptPath, &pb); sifterErr == nil { if len(pb.Pipelines) > 0 || len(pb.Inputs) > 0 { err := graphplan.NewGraphBuild( - &pb, outScriptDir, outDataDir, + &pb, outScriptDir, outDataDir, objectExclude, ) if err != nil { - log.Printf("Error: %s\n", err) + logger.Error("Parse Error", "error", err) } } } @@ -54,6 +60,8 @@ var Cmd = &cobra.Command{ func init() { flags := Cmd.Flags() + flags.BoolVarP(&verbose, "verbose", "v", verbose, "Verbose logging") flags.StringVarP(&outScriptDir, "dir", "C", outScriptDir, "Change Directory for script base") flags.StringVarP(&outDataDir, "out", "o", outDataDir, "Change output Directory") + flags.StringArrayVarP(&objectExclude, "exclude", "x", objectExclude, "Object Exclude") } diff --git a/cmd/inspect/main.go b/cmd/inspect/main.go index e01909c..4375f45 100644 --- a/cmd/inspect/main.go +++ b/cmd/inspect/main.go @@ -3,16 +3,15 @@ package inspect import ( "encoding/json" "fmt" - "log" "path/filepath" + "github.com/bmeg/sifter/logger" "github.com/bmeg/sifter/playbook" "github.com/bmeg/sifter/task" "github.com/spf13/cobra" ) var outDir string = "" -var inputFile string = "" var cmdInputs map[string]string // Cmd is the declaration of the command line @@ -31,12 +30,12 @@ var Cmd = &cobra.Command{ pb := playbook.Playbook{} if err := playbook.ParseFile(playFile, &pb); err != nil { - log.Printf("%s", err) + logger.Info("%s", err) return err } var err error inputs, err = pb.PrepConfig(inputs, "./") - log.Printf("inputs: %s", inputs) + logger.Info("inputs: %s", inputs) if err != nil { return err } @@ -45,7 +44,7 @@ var Cmd = &cobra.Command{ outDir = pb.GetDefaultOutDir() } - log.Printf("outdir: %s", outDir) + logger.Info("outdir: %s", outDir) p, _ := filepath.Abs(playFile) baseDir := filepath.Dir(p) diff --git a/cmd/run/main.go b/cmd/run/main.go index a379679..5163223 100644 --- a/cmd/run/main.go +++ b/cmd/run/main.go @@ -1,37 +1,35 @@ package run import ( - "io/ioutil" - "log" + "io" "os" + "github.com/bmeg/sifter/logger" "github.com/bmeg/sifter/playbook" "github.com/spf13/cobra" ) -var workDir string = "./" var outDir string = "" -var resume string = "" -var graph string = "" var inputFile string = "" -var toStdout bool -var keep bool +var verbose bool = false var cmdInputs map[string]string -var proxy = "" -var port = 8888 - // Cmd is the declaration of the command line var Cmd = &cobra.Command{ Use: "run