From 2d2adc6c6bb89272b58356667bd089e9a99dcecc Mon Sep 17 00:00:00 2001 From: derailed Date: Fri, 1 May 2020 14:45:30 -0600 Subject: [PATCH] cleaning up --- internal/view/actions.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/internal/view/actions.go b/internal/view/actions.go index c05b38fd..135b933d 100644 --- a/internal/view/actions.go +++ b/internal/view/actions.go @@ -120,7 +120,6 @@ func pluginAction(r Runner, p config.Plugin) ui.ActionHandler { if path == "" { return evt } - if r.EnvFn() == nil { return nil } @@ -134,20 +133,26 @@ func pluginAction(r Runner, p config.Plugin) ui.ActionHandler { } args[i] = arg } - fn := func() { - if run(r.App(), shellOpts{clear: true, binary: p.Command, background: p.Background, args: args}) { - r.App().Flash().Info("Plugin command launched successfully!") - } else { - r.App().Flash().Info("Plugin command failed!") + + cb := func() { + opts := shellOpts{ + clear: true, + 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 { - dialog.ShowConfirm(r.App().Content.Pages, "Confirm plugin action", fmt.Sprintf("Will execute:\n%s %s", p.Command, strings.Join(args, " ")), func() { - fn() - }, func() {}) - } else { - fn() + msg := fmt.Sprintf("Run?\n%s %s", p.Command, strings.Join(args, " ")) + dialog.ShowConfirm(r.App().Content.Pages, "Confirm "+p.Description, msg, cb, func() {}) + return nil } + cb() return nil }