summary refs log tree commit diff stats
path: root/widgets/account.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-14 08:14:03 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-14 08:14:03 -0500
commit8492a21a51c107f743a32231746bf5d38e9b1ccd (patch)
treeb0ed6d96dbc664c57bb9a0d1488ab4fec2e12f37 /widgets/account.go
parentd35213eaabeda8749cd0aab103e5895cfcd96e94 (diff)
downloadaerc-8492a21a51c107f743a32231746bf5d38e9b1ccd.tar.gz
Send commands up to the top-level aerc widget
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 8662c0c..54eb9e9 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -20,13 +20,14 @@ type AccountView struct {
 	logger       *log.Logger
 	interactive  ui.Interactive
 	onInvalidate func(d ui.Drawable)
+	runCmd       func(cmd string) error
 	statusline   *StatusLine
 	statusbar    *ui.Stack
 	worker       *types.Worker
 }
 
-func NewAccountView(
-	conf *config.AccountConfig, logger *log.Logger) *AccountView {
+func NewAccountView(conf *config.AccountConfig,
+	logger *log.Logger, runCmd func(cmd string) error) *AccountView {
 
 	statusbar := ui.NewStack()
 	statusline := NewStatusLine()
@@ -63,6 +64,7 @@ func NewAccountView(
 		dirlist:    dirlist,
 		grid:       grid,
 		logger:     logger,
+		runCmd:     runCmd,
 		statusline: statusline,
 		statusbar:  statusbar,
 		worker:     worker,
@@ -106,8 +108,12 @@ func (acct *AccountView) Event(event tcell.Event) bool {
 	case *tcell.EventKey:
 		if event.Rune() == ':' {
 			exline := NewExLine(func(command string) {
-				acct.statusline.Push(
-					fmt.Sprintf("TODO: execute %s", command), 3*time.Second)
+				err := acct.runCmd(command)
+				if err != nil {
+					acct.statusline.Push(
+						fmt.Sprintf("Error: %v", err), 3*time.Second).
+						Color(tcell.ColorRed, tcell.ColorDefault)
+				}
 				acct.statusbar.Pop()
 				acct.interactive = nil
 			}, func() {