1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-07-09 07:00:21 +02:00
aerc/commands/account/next-result.go
Robin Jarry 26033eaecf completion: add commands descriptions
Update the Command interface to include a Description() method.
Implement the method for all commands using short descriptions inspired
from the aerc(1) man page.

Return the description values along with command names so that they can
be displayed in completion choices.

Implements: https://todo.sr.ht/~rjarry/aerc/271
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bojan Gabric <bojan@bojangabric.com>
Tested-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-23 10:22:51 +02:00

48 lines
889 B
Go

package account
import (
"errors"
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib/ui"
)
type NextPrevResult struct{}
func init() {
commands.Register(NextPrevResult{})
}
func (NextPrevResult) Description() string {
return "Select the next or previous search result."
}
func (NextPrevResult) Context() commands.CommandContext {
return commands.MESSAGE_LIST
}
func (NextPrevResult) Aliases() []string {
return []string{"next-result", "prev-result"}
}
func (NextPrevResult) Execute(args []string) error {
acct := app.SelectedAccount()
if acct == nil {
return errors.New("No account selected")
}
if args[0] == "prev-result" {
store := acct.Store()
if store != nil {
store.PrevResult()
}
ui.Invalidate()
} else {
store := acct.Store()
if store != nil {
store.NextResult()
}
ui.Invalidate()
}
return nil
}