aerc/commands/help.go

45 lines
724 B
Go
Raw Permalink Normal View History

2019-05-22 15:17:52 +00:00
package commands
import (
"errors"
"git.sr.ht/~rjarry/aerc/widgets"
2019-05-22 15:17:52 +00:00
)
type Help struct{}
var pages = []string{
"aerc",
"config",
"imap",
"notmuch",
"search",
"sendmail",
"smtp",
"stylesets",
"templates",
"tutorial",
}
2019-05-22 15:17:52 +00:00
func init() {
register(Help{})
}
func (Help) Aliases() []string {
return []string{"help"}
}
func (Help) Complete(aerc *widgets.Aerc, args []string) []string {
return CompletionFromList(aerc, pages, args)
2019-05-22 15:17:52 +00:00
}
func (Help) Execute(aerc *widgets.Aerc, args []string) error {
2019-05-22 15:17:52 +00:00
page := "aerc"
if len(args) == 2 && args[1] != "aerc" {
2019-05-22 15:17:52 +00:00
page = "aerc-" + args[1]
} else if len(args) > 2 {
return errors.New("Usage: help [topic]")
}
return TermCore(aerc, []string{"term", "man", page})
2019-05-22 15:17:52 +00:00
}