diff options
author | Christopher Vittal <christopher.vittal@gmail.com> | 2019-08-19 21:56:12 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-08-26 09:48:39 +0900 |
commit | ecd803aae4ea1ba23d291325d52a53c19216e64b (patch) | |
tree | a560d5a88b332a39c0519a21ae05f5dc309545a3 /commands/prompt.go | |
parent | ea4fe713607e40cf19df37cdd0699cacba7313a3 (diff) |
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/prompt.go')
-rw-r--r-- | commands/prompt.go | 33 |
1 files changed, 33 insertions, 0 deletions
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 <prompt> <cmd>", args[0])) + } + + prompt := args[1] + cmd := args[2:] + aerc.RegisterPrompt(prompt, cmd) + return nil +} |