diff --git a/README.md b/README.md index d2cf4d4..9a5c41a 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Various operations can be programmed for each project, which can be executed at - Custom arguments to pass at each project - Docker support (only with polling watcher) - Live reload on file change (extensions and paths customizable) -- Support for most go commands (install, build, run, vet, test, fmt and much more) +- Support for most go commands (install, build, run, vet, test, fmt, fix, clean) - Web panel for a smart control of the workflow Next features and informations diff --git a/realize.go b/realize.go index f3ec339..27fff9b 100644 --- a/realize.go +++ b/realize.go @@ -509,6 +509,94 @@ func main() { return nil }, }, + { + Before: func(d interact.Context) error { + d.SetDef(false, green.regular("(n)")) + return nil + }, + Quest: interact.Quest{ + Options: yellow.regular("[y/n]"), + Msg: "Enable go fix", + Resolve: func(d interact.Context) bool { + val, _ := d.Ans().Bool() + return val + }, + }, + Subs: []*interact.Question{ + { + Before: func(d interact.Context) error { + d.SetDef("", green.regular("(none)")) + return nil + }, + Quest: interact.Quest{ + Options: yellow.regular("[string]"), + Msg: "Fix additional arguments", + }, + Action: func(d interact.Context) interface{} { + val, err := d.Ans().String() + if err != nil { + return d.Err() + } + if val != "" { + r.Schema[len(r.Schema)-1].Cmds.Fix.Args = append(r.Schema[len(r.Schema)-1].Cmds.Fix.Args, val) + } + return nil + }, + }, + }, + Action: func(d interact.Context) interface{} { + val, err := d.Ans().Bool() + if err != nil { + return d.Err() + } + r.Schema[len(r.Schema)-1].Cmds.Fix.Status = val + return nil + }, + }, + { + Before: func(d interact.Context) error { + d.SetDef(false, green.regular("(n)")) + return nil + }, + Quest: interact.Quest{ + Options: yellow.regular("[y/n]"), + Msg: "Enable go clean", + Resolve: func(d interact.Context) bool { + val, _ := d.Ans().Bool() + return val + }, + }, + Subs: []*interact.Question{ + { + Before: func(d interact.Context) error { + d.SetDef("", green.regular("(none)")) + return nil + }, + Quest: interact.Quest{ + Options: yellow.regular("[string]"), + Msg: "Clean additional arguments", + }, + Action: func(d interact.Context) interface{} { + val, err := d.Ans().String() + if err != nil { + return d.Err() + } + if val != "" { + r.Schema[len(r.Schema)-1].Cmds.Clean.Args = append(r.Schema[len(r.Schema)-1].Cmds.Clean.Args, val) + } + return nil + }, + }, + }, + Action: func(d interact.Context) interface{} { + val, err := d.Ans().Bool() + if err != nil { + return d.Err() + } + r.Schema[len(r.Schema)-1].Cmds.Clean.Status = val + return nil + }, + }, { Before: func(d interact.Context) error { d.SetDef(false, green.regular("(n)"))