go clean and fix support

This commit is contained in:
asoseil 2017-11-05 22:53:31 +01:00
parent 11f74c1ce4
commit ae5497149d
2 changed files with 89 additions and 1 deletions

View File

@ -49,7 +49,7 @@ Various operations can be programmed for each project, which can be executed at
- Custom arguments to pass at each project - Custom arguments to pass at each project
- Docker support (only with polling watcher) - Docker support (only with polling watcher)
- Live reload on file change (extensions and paths customizable) - 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 - Web panel for a smart control of the workflow
Next features and informations Next features and informations

View File

@ -509,6 +509,94 @@ func main() {
return nil 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 { Before: func(d interact.Context) error {
d.SetDef(false, green.regular("(n)")) d.SetDef(false, green.regular("(n)"))