aboutsummaryrefslogtreecommitdiffstats
path: root/commands/prompt.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/prompt.go')
-rw-r--r--commands/prompt.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/commands/prompt.go b/commands/prompt.go
index 0d10ffa0..d42a6597 100644
--- a/commands/prompt.go
+++ b/commands/prompt.go
@@ -1,7 +1,6 @@
package commands
import (
- "fmt"
"strings"
"git.sr.ht/~rjarry/go-opt"
@@ -9,7 +8,10 @@ import (
"git.sr.ht/~rjarry/aerc/app"
)
-type Prompt struct{}
+type Prompt struct {
+ Text string `opt:"text"`
+ Cmd []string `opt:"..."`
+}
func init() {
register(Prompt{})
@@ -71,13 +73,8 @@ func (Prompt) Complete(args []string) []string {
return rs
}
-func (Prompt) Execute(args []string) error {
- if len(args) < 3 {
- return fmt.Errorf("Usage: %s <prompt> <cmd>", args[0])
- }
-
- prompt := args[1]
- cmd := opt.QuoteArgs(args[2:]...)
- app.RegisterPrompt(prompt, cmd.String())
+func (p Prompt) Execute(args []string) error {
+ cmd := opt.QuoteArgs(p.Cmd...)
+ app.RegisterPrompt(p.Text, cmd.String())
return nil
}