aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/aerc.go33
-rw-r--r--app/app.go1
2 files changed, 27 insertions, 7 deletions
diff --git a/app/aerc.go b/app/aerc.go
index 7418e979..667696f7 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -698,7 +698,31 @@ func (aerc *Aerc) RegisterChoices(choices []Choice) {
aerc.prompts.Push(p)
}
-func (aerc *Aerc) Mailto(addr *url.URL) error {
+func (aerc *Aerc) Command(args []string) error {
+ switch {
+ case len(args) == 0:
+ return nil // noop success, i.e. ping
+ case strings.HasPrefix(args[0], "mailto:"):
+ mailto, err := url.Parse(args[0])
+ if err != nil {
+ return err
+ }
+ return aerc.mailto(mailto)
+ case strings.HasPrefix(args[0], "mbox:"):
+ return aerc.mbox(args[0])
+ case strings.HasPrefix(args[0], ":"):
+ cmdline := args[0]
+ if len(args) > 1 {
+ cmdline = opt.QuoteArgs(args...).String()
+ }
+ defer ui.Invalidate()
+ return aerc.cmd(cmdline, nil, nil)
+ default:
+ return errors.New("command not understood")
+ }
+}
+
+func (aerc *Aerc) mailto(addr *url.URL) error {
var subject string
var body string
var acctName string
@@ -790,7 +814,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
return nil
}
-func (aerc *Aerc) Mbox(source string) error {
+func (aerc *Aerc) mbox(source string) error {
acctConf := config.AccountConfig{}
if selectedAcct := aerc.SelectedAccount(); selectedAcct != nil {
acctConf = *selectedAcct.acct
@@ -819,11 +843,6 @@ func (aerc *Aerc) Mbox(source string) error {
return nil
}
-func (aerc *Aerc) Command(cmd string) error {
- defer ui.Invalidate()
- return aerc.cmd(cmd, nil, nil)
-}
-
func (aerc *Aerc) CloseBackends() error {
var returnErr error
for _, acct := range aerc.accounts {
diff --git a/app/app.go b/app/app.go
index ca9c59bb..7e06ce3b 100644
--- a/app/app.go
+++ b/app/app.go
@@ -26,6 +26,7 @@ func Init(
func Drawable() ui.DrawableInteractive { return &aerc }
func IPCHandler() ipc.Handler { return &aerc }
+func Command(args []string) error { return aerc.Command(args) }
func HandleMessage(msg types.WorkerMessage) { aerc.HandleMessage(msg) }
func CloseBackends() error { return aerc.CloseBackends() }