code review
This commit is contained in:
parent
bccfaca01d
commit
b7c50a2efb
16
realize.go
16
realize.go
|
@ -122,25 +122,25 @@ func main() {
|
||||||
},
|
},
|
||||||
Action: func(p *cli.Context) error {
|
Action: func(p *cli.Context) error {
|
||||||
c := r
|
c := r
|
||||||
if p.String("name") != ""{
|
if p.String("name") != "" {
|
||||||
for index, project := range r.Blueprint.Projects{
|
for index, project := range r.Blueprint.Projects {
|
||||||
if project.Name == p.String("name"){
|
if project.Name == p.String("name") {
|
||||||
c.Blueprint.Projects = []watcher.Project{r.Blueprint.Projects[index]}
|
c.Blueprint.Projects = []watcher.Project{r.Blueprint.Projects[index]}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.Bool("legacy") {
|
if p.Bool("legacy") {
|
||||||
r.Config.Legacy = settings.Legacy{
|
c.Config.Legacy = settings.Legacy{
|
||||||
Status: p.Bool("legacy"),
|
Status: p.Bool("legacy"),
|
||||||
Interval: interval,
|
Interval: interval,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.Bool("no-config") || len(r.Blueprint.Projects) <= 0 {
|
if p.Bool("no-config") || len(c.Blueprint.Projects) <= 0 {
|
||||||
if p.Bool("no-config") {
|
if p.Bool("no-config") {
|
||||||
r.Config.Create = false
|
c.Config.Create = false
|
||||||
}
|
}
|
||||||
r.Blueprint.Projects = []watcher.Project{}
|
c.Blueprint.Projects = []watcher.Project{}
|
||||||
if err := r.Blueprint.Add(p); err != nil {
|
if err := c.Blueprint.Add(p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
yaml "gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var Dir = ".realize/"
|
var Dir = ".realize/"
|
||||||
|
|
|
@ -16,7 +16,7 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
||||||
wg.Add(len(h.Projects))
|
wg.Add(len(h.Projects))
|
||||||
for k, element := range h.Projects {
|
for k, element := range h.Projects {
|
||||||
tools := tools{}
|
tools := tools{}
|
||||||
if element.Cmds.Fmt{
|
if element.Cmds.Fmt {
|
||||||
tools.Fmt = tool{
|
tools.Fmt = tool{
|
||||||
status: &h.Projects[k].Cmds.Fmt,
|
status: &h.Projects[k].Cmds.Fmt,
|
||||||
cmd: "gofmt",
|
cmd: "gofmt",
|
||||||
|
@ -24,7 +24,7 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
||||||
name: "Go Fmt",
|
name: "Go Fmt",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if element.Cmds.Generate{
|
if element.Cmds.Generate {
|
||||||
tools.Generate = tool{
|
tools.Generate = tool{
|
||||||
status: &h.Projects[k].Cmds.Generate,
|
status: &h.Projects[k].Cmds.Generate,
|
||||||
cmd: "go",
|
cmd: "go",
|
||||||
|
@ -32,7 +32,7 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
||||||
name: "Go Generate",
|
name: "Go Generate",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if element.Cmds.Test{
|
if element.Cmds.Test {
|
||||||
tools.Test = tool{
|
tools.Test = tool{
|
||||||
status: &h.Projects[k].Cmds.Test,
|
status: &h.Projects[k].Cmds.Test,
|
||||||
cmd: "go",
|
cmd: "go",
|
||||||
|
@ -178,5 +178,5 @@ func (h *Blueprint) check() error {
|
||||||
h.Clean()
|
h.Clean()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("there are no projects")
|
return errors.New("There are no projects")
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,10 +286,10 @@ func (p *Project) tool(path string, tool tool) error {
|
||||||
// Cmd calls an wrapper for execute the commands after/before
|
// Cmd calls an wrapper for execute the commands after/before
|
||||||
func (p *Project) cmd(flag string, changed bool) {
|
func (p *Project) cmd(flag string, changed bool) {
|
||||||
for _, cmd := range p.Watcher.Scripts {
|
for _, cmd := range p.Watcher.Scripts {
|
||||||
if strings.ToLower(cmd.Type) == flag{
|
if strings.ToLower(cmd.Type) == flag {
|
||||||
if changed && cmd.Changed || !changed && cmd.Startup {
|
if changed && cmd.Changed || !changed && cmd.Startup {
|
||||||
errors, logs := p.command(cmd)
|
errors, logs := p.command(cmd)
|
||||||
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"") + cmd.Command + style.Green.Bold("\""))
|
msg = fmt.Sprintln(p.pname(p.Name, 5), ":", style.Green.Bold("Command"), style.Green.Bold("\"")+cmd.Command+style.Green.Bold("\""))
|
||||||
out = BufferOut{Time: time.Now(), Text: cmd.Command, Type: flag}
|
out = BufferOut{Time: time.Now(), Text: cmd.Command, Type: flag}
|
||||||
if logs != "" {
|
if logs != "" {
|
||||||
p.print("log", out, msg, "")
|
p.print("log", out, msg, "")
|
||||||
|
@ -323,7 +323,7 @@ func (p *Project) ignore(str string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Routines launches the toolchain run, build, install
|
// Routines launches the toolchain run, build, install
|
||||||
func (p *Project) routines(wr *sync.WaitGroup,channel chan bool, watcher watcher, file string) {
|
func (p *Project) routines(wr *sync.WaitGroup, channel chan bool, watcher watcher, file string) {
|
||||||
if len(file) > 0 {
|
if len(file) > 0 {
|
||||||
p.cmd("before", true)
|
p.cmd("before", true)
|
||||||
path := filepath.Dir(file)
|
path := filepath.Dir(file)
|
||||||
|
|
Loading…
Reference in New Issue