diff --git a/realize.go b/realize.go index 2042088..c925635 100644 --- a/realize.go +++ b/realize.go @@ -17,14 +17,13 @@ import ( const ( appVersion = "1.3" - - config = "realize.yaml" - outputs = "outputs.log" - errs = "errors.log" - logs = "logs.log" - host = "localhost" - port = 5001 - interval = 200 + config = "realize.yaml" + outputs = "outputs.log" + errs = "errors.log" + logs = "logs.log" + host = "localhost" + port = 5001 + interval = 200 ) // Cli commands @@ -195,7 +194,7 @@ func main() { Questions: []*interact.Question{ { Before: func(d interact.Context) error { - if _, err := os.Stat(".realize/" + config); err != nil { + if _, err := os.Stat(settings.Dir + config); err != nil { d.Skip() } d.SetDef(false, style.Green.Regular("(n)")) @@ -462,7 +461,25 @@ func main() { if err != nil { return d.Err() } - r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Fmt = val + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Cmds.Fmt = val + return nil + }, + }, + { + Before: func(d interact.Context) error { + d.SetDef(true, style.Green.Regular("(y)")) + return nil + }, + Quest: interact.Quest{ + Options: style.Yellow.Regular("[y/n]"), + Msg: "Enable go vet", + }, + Action: func(d interact.Context) interface{} { + val, err := d.Ans().Bool() + if err != nil { + return d.Err() + } + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Cmds.Vet = val return nil }, }, @@ -480,7 +497,7 @@ func main() { if err != nil { return d.Err() } - r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Test = val + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Cmds.Test = val return nil }, }, @@ -498,7 +515,7 @@ func main() { if err != nil { return d.Err() } - r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Generate = val + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Cmds.Generate = val return nil }, }, @@ -516,7 +533,7 @@ func main() { if err != nil { return d.Err() } - r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Bin = val + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Cmds.Bin.Status = val return nil }, }, @@ -534,7 +551,7 @@ func main() { if err != nil { return d.Err() } - r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Build = val + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Cmds.Build.Status = val return nil }, }, @@ -552,7 +569,7 @@ func main() { if err != nil { return d.Err() } - r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Run = val + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Cmds.Run = val return nil }, }, @@ -674,7 +691,7 @@ func main() { if err != nil { return d.Err() } - r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Params = append(r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Params, val) + r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Args = append(r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Args, val) d.Reload() return nil }, diff --git a/settings/io.go b/settings/io.go index e3fc2c3..d622ee8 100644 --- a/settings/io.go +++ b/settings/io.go @@ -26,8 +26,8 @@ func (s Settings) Write(name string, data []byte) error { // Create a new file and return its pointer func (s Settings) Create(path string, name string) *os.File { var file string - if _, err := os.Stat(".realize/"); err == nil { - file = filepath.Join(path, ".realize/", name) + if _, err := os.Stat(Dir); err == nil { + file = filepath.Join(path, Dir, name) } else { file = filepath.Join(path, name) } diff --git a/settings/settings.go b/settings/settings.go index 58ae93a..41a4054 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -7,6 +7,8 @@ import ( yaml "gopkg.in/yaml.v2" ) +var Dir = ".realize/" + // Settings defines a group of general settings type Settings struct { Config `yaml:",inline" json:"config"` @@ -46,8 +48,8 @@ type Resources struct { // Read from config file func (s *Settings) Read(out interface{}) error { localConfigPath := s.Resources.Config - if _, err := os.Stat(".realize/" + s.Resources.Config); err == nil { - localConfigPath = ".realize/" + s.Resources.Config + if _, err := os.Stat(Dir + s.Resources.Config); err == nil { + localConfigPath = Dir + s.Resources.Config } content, err := s.Stream(localConfigPath) if err == nil { @@ -64,20 +66,20 @@ func (s *Settings) Record(out interface{}) error { if err != nil { return err } - if _, err := os.Stat(".realize/"); os.IsNotExist(err) { - if err = os.Mkdir(".realize/", 0770); err != nil { + if _, err := os.Stat(Dir); os.IsNotExist(err) { + if err = os.Mkdir(Dir, 0770); err != nil { return s.Write(s.Resources.Config, y) } } - return s.Write(".realize/"+s.Resources.Config, y) + return s.Write(Dir+s.Resources.Config, y) } return nil } // Remove realize folder func (s *Settings) Remove() error { - if _, err := os.Stat(".realize/"); !os.IsNotExist(err) { - return os.RemoveAll(".realize/") + if _, err := os.Stat(Dir); !os.IsNotExist(err) { + return os.RemoveAll(Dir) } return nil }