From ecd803aae4ea1ba23d291325d52a53c19216e64b Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Mon, 19 Aug 2019 21:56:12 -0400 Subject: Add :prompt command Usage: :prompt Displays the prompt on the status bar, waits for user input, then appends that input as the last argument to the command and executes it. The input is passed as one argument to the command, unless it is empty, in which case no extra argument is added. --- commands/prompt.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 commands/prompt.go (limited to 'commands') diff --git a/commands/prompt.go b/commands/prompt.go new file mode 100644 index 0000000..3734881 --- /dev/null +++ b/commands/prompt.go @@ -0,0 +1,33 @@ +package commands + +import ( + "errors" + "fmt" + + "git.sr.ht/~sircmpwn/aerc/widgets" +) + +type Prompt struct{} + +func init() { + register(Prompt{}) +} + +func (_ Prompt) Aliases() []string { + return []string{"prompt"} +} + +func (_ Prompt) Complete(aerc *widgets.Aerc, args []string) []string { + return nil // TODO: add completions +} + +func (_ Prompt) Execute(aerc *widgets.Aerc, args []string) error { + if len(args) < 3 { + return errors.New(fmt.Sprintf("Usage: %s ", args[0])) + } + + prompt := args[1] + cmd := args[2:] + aerc.RegisterPrompt(prompt, cmd) + return nil +} -- cgit v1.2.3