cleaning up

mine
derailed 2020-05-01 14:45:30 -06:00
parent d4f6700ce1
commit 2d2adc6c6b
1 changed files with 16 additions and 11 deletions

View File

@ -120,7 +120,6 @@ func pluginAction(r Runner, p config.Plugin) ui.ActionHandler {
if path == "" { if path == "" {
return evt return evt
} }
if r.EnvFn() == nil { if r.EnvFn() == nil {
return nil return nil
} }
@ -134,20 +133,26 @@ func pluginAction(r Runner, p config.Plugin) ui.ActionHandler {
} }
args[i] = arg args[i] = arg
} }
fn := func() {
if run(r.App(), shellOpts{clear: true, binary: p.Command, background: p.Background, args: args}) { cb := func() {
r.App().Flash().Info("Plugin command launched successfully!") opts := shellOpts{
} else { clear: true,
r.App().Flash().Info("Plugin command failed!") binary: p.Command,
background: p.Background,
args: args,
} }
if run(r.App(), opts) {
r.App().Flash().Info("Plugin command launched successfully!")
return
}
r.App().Flash().Info("Plugin command failed!")
} }
if p.Confirm { if p.Confirm {
dialog.ShowConfirm(r.App().Content.Pages, "Confirm plugin action", fmt.Sprintf("Will execute:\n%s %s", p.Command, strings.Join(args, " ")), func() { msg := fmt.Sprintf("Run?\n%s %s", p.Command, strings.Join(args, " "))
fn() dialog.ShowConfirm(r.App().Content.Pages, "Confirm "+p.Description, msg, cb, func() {})
}, func() {}) return nil
} else {
fn()
} }
cb()
return nil return nil
} }