aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorChristopher Vittal <christopher.vittal@gmail.com>2019-08-19 21:56:12 -0400
committerDrew DeVault <sir@cmpwn.com>2019-08-26 09:48:39 +0900
commitecd803aae4ea1ba23d291325d52a53c19216e64b (patch)
treea560d5a88b332a39c0519a21ae05f5dc309545a3 /commands
parentea4fe713607e40cf19df37cdd0699cacba7313a3 (diff)
downloadaerc-ecd803aae4ea1ba23d291325d52a53c19216e64b.tar.gz
Add :prompt command
Usage: :prompt <prompt> <command...> 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.
Diffstat (limited to 'commands')
-rw-r--r--commands/prompt.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/commands/prompt.go b/commands/prompt.go
new file mode 100644
index 00000000..37348813
--- /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 <prompt> <cmd>", args[0]))
+ }
+
+ prompt := args[1]
+ cmd := args[2:]
+ aerc.RegisterPrompt(prompt, cmd)
+ return nil
+}