Implement basic tab completion support
Tab completion currently only works on commands. Contextual completion will be added in the future.
This commit is contained in:
parent
177651bdda
commit
2a0961701c
47 changed files with 598 additions and 154 deletions
|
@ -18,11 +18,21 @@ const (
|
|||
ARCHIVE_MONTH = "month"
|
||||
)
|
||||
|
||||
type Archive struct{}
|
||||
|
||||
func init() {
|
||||
register("archive", Archive)
|
||||
register(Archive{})
|
||||
}
|
||||
|
||||
func Archive(aerc *widgets.Aerc, args []string) error {
|
||||
func (_ Archive) Aliases() []string {
|
||||
return []string{"archive"}
|
||||
}
|
||||
|
||||
func (_ Archive) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ Archive) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) != 2 {
|
||||
return errors.New("Usage: archive <flat|year|month>")
|
||||
}
|
||||
|
|
|
@ -11,12 +11,21 @@ import (
|
|||
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
||||
)
|
||||
|
||||
type Copy struct{}
|
||||
|
||||
func init() {
|
||||
register("cp", Copy)
|
||||
register("copy", Copy)
|
||||
register(Copy{})
|
||||
}
|
||||
|
||||
func Copy(aerc *widgets.Aerc, args []string) error {
|
||||
func (_ Copy) Aliases() []string {
|
||||
return []string{"copy"}
|
||||
}
|
||||
|
||||
func (_ Copy) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ Copy) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
opts, optind, err := getopt.Getopts(args, "p")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -10,12 +10,21 @@ import (
|
|||
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
||||
)
|
||||
|
||||
type Delete struct{}
|
||||
|
||||
func init() {
|
||||
register("delete", DeleteMessage)
|
||||
register("delete-message", DeleteMessage)
|
||||
register(Delete{})
|
||||
}
|
||||
|
||||
func DeleteMessage(aerc *widgets.Aerc, args []string) error {
|
||||
func (_ Delete) Aliases() []string {
|
||||
return []string{"delete", "delete-message"}
|
||||
}
|
||||
|
||||
func (_ Delete) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ Delete) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) != 1 {
|
||||
return errors.New("Usage: :delete")
|
||||
}
|
||||
|
|
|
@ -11,12 +11,21 @@ import (
|
|||
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
||||
)
|
||||
|
||||
type Move struct{}
|
||||
|
||||
func init() {
|
||||
register("mv", Move)
|
||||
register("move", Move)
|
||||
register(Move{})
|
||||
}
|
||||
|
||||
func Move(aerc *widgets.Aerc, args []string) error {
|
||||
func (_ Move) Aliases() []string {
|
||||
return []string{"mv", "move"}
|
||||
}
|
||||
|
||||
func (_ Move) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ Move) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
opts, optind, err := getopt.Getopts(args, "p")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -8,9 +8,9 @@ var (
|
|||
MessageCommands *commands.Commands
|
||||
)
|
||||
|
||||
func register(name string, cmd commands.AercCommand) {
|
||||
func register(cmd commands.Command) {
|
||||
if MessageCommands == nil {
|
||||
MessageCommands = commands.NewCommands()
|
||||
}
|
||||
MessageCommands.Register(name, cmd)
|
||||
MessageCommands.Register(cmd)
|
||||
}
|
||||
|
|
|
@ -10,12 +10,21 @@ import (
|
|||
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
||||
)
|
||||
|
||||
type Read struct{}
|
||||
|
||||
func init() {
|
||||
register("read", Read)
|
||||
register("unread", Read)
|
||||
register(Read{})
|
||||
}
|
||||
|
||||
func Read(aerc *widgets.Aerc, args []string) error {
|
||||
func (_ Read) Aliases() []string {
|
||||
return []string{"read", "unread"}
|
||||
}
|
||||
|
||||
func (_ Read) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ Read) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) != 1 {
|
||||
return errors.New("Usage: " + args[0])
|
||||
}
|
||||
|
|
|
@ -18,12 +18,21 @@ import (
|
|||
"git.sr.ht/~sircmpwn/aerc/widgets"
|
||||
)
|
||||
|
||||
type reply struct{}
|
||||
|
||||
func init() {
|
||||
register("reply", Reply)
|
||||
register("forward", Reply)
|
||||
register(reply{})
|
||||
}
|
||||
|
||||
func Reply(aerc *widgets.Aerc, args []string) error {
|
||||
func (_ reply) Aliases() []string {
|
||||
return []string{"reply", "forward"}
|
||||
}
|
||||
|
||||
func (_ reply) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_ reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||
opts, optind, err := getopt.Getopts(args, "aq")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue