diff options
Diffstat (limited to 'commands/prompt.go')
-rw-r--r-- | commands/prompt.go | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/commands/prompt.go b/commands/prompt.go index 3d84703d..0fa76ff7 100644 --- a/commands/prompt.go +++ b/commands/prompt.go @@ -1,14 +1,15 @@ package commands import ( - "fmt" "strings" - "git.sr.ht/~rjarry/aerc/lib/opt" "git.sr.ht/~rjarry/aerc/widgets" ) -type Prompt struct{} +type Prompt struct { + Text string `opt:"TEXT"` + Cmd string `opt:"..."` +} func init() { register(Prompt{}) @@ -70,16 +71,7 @@ func (Prompt) Complete(aerc *widgets.Aerc, args []string) []string { return rs } -func (Prompt) Execute(aerc *widgets.Aerc, args []string) error { - if len(args) < 3 { - return fmt.Errorf("Usage: %s <prompt> <cmd>", args[0]) - } - - prompt := args[1] - cmd, err := opt.QuoteArgs(args[2:]...) - if err != nil { - return err - } - aerc.RegisterPrompt(prompt, cmd.String()) +func (p Prompt) Execute(aerc *widgets.Aerc, args []string) error { + aerc.RegisterPrompt(p.Text, p.Cmd) return nil } |