diff options
author | Gregory Mullen <greg@cmdline.org> | 2019-06-27 10:33:11 -0700 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-29 14:24:19 -0400 |
commit | 2a0961701c4cabecc53d134ed1782e5612e64580 (patch) | |
tree | 57952ac82fb7104113ca7fc0e25dc3d225f77ea7 /commands/msg | |
parent | 177651bddab145c8a56cdfeb0d57b5fd95a6d0e2 (diff) | |
download | aerc-2a0961701c4cabecc53d134ed1782e5612e64580.tar.gz |
Implement basic tab completion support
Tab completion currently only works on commands. Contextual completion
will be added in the future.
Diffstat (limited to 'commands/msg')
-rw-r--r-- | commands/msg/archive.go | 14 | ||||
-rw-r--r-- | commands/msg/copy.go | 15 | ||||
-rw-r--r-- | commands/msg/delete.go | 15 | ||||
-rw-r--r-- | commands/msg/move.go | 15 | ||||
-rw-r--r-- | commands/msg/msg.go | 4 | ||||
-rw-r--r-- | commands/msg/read.go | 15 | ||||
-rw-r--r-- | commands/msg/reply.go | 15 |
7 files changed, 74 insertions, 19 deletions
diff --git a/commands/msg/archive.go b/commands/msg/archive.go index 4fe73306..40fb48bc 100644 --- a/commands/msg/archive.go +++ b/commands/msg/archive.go @@ -18,11 +18,21 @@ const ( ARCHIVE_MONTH = "month" ) +type Archive struct{} + func init() { - register("archive", Archive) + register(Archive{}) +} + +func (_ Archive) Aliases() []string { + return []string{"archive"} +} + +func (_ Archive) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func Archive(aerc *widgets.Aerc, args []string) error { +func (_ Archive) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 2 { return errors.New("Usage: archive <flat|year|month>") } diff --git a/commands/msg/copy.go b/commands/msg/copy.go index 0735e98f..4d65d249 100644 --- a/commands/msg/copy.go +++ b/commands/msg/copy.go @@ -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) Aliases() []string { + return []string{"copy"} +} + +func (_ Copy) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func Copy(aerc *widgets.Aerc, args []string) error { +func (_ Copy) Execute(aerc *widgets.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, "p") if err != nil { return err diff --git a/commands/msg/delete.go b/commands/msg/delete.go index ee3dd290..5a72fc9b 100644 --- a/commands/msg/delete.go +++ b/commands/msg/delete.go @@ -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 (_ Delete) Aliases() []string { + return []string{"delete", "delete-message"} +} + +func (_ Delete) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func DeleteMessage(aerc *widgets.Aerc, args []string) error { +func (_ Delete) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: :delete") } diff --git a/commands/msg/move.go b/commands/msg/move.go index 23670768..45199b63 100644 --- a/commands/msg/move.go +++ b/commands/msg/move.go @@ -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) Aliases() []string { + return []string{"mv", "move"} +} + +func (_ Move) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func Move(aerc *widgets.Aerc, args []string) error { +func (_ Move) Execute(aerc *widgets.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, "p") if err != nil { return err diff --git a/commands/msg/msg.go b/commands/msg/msg.go index 73755aa8..ecf21029 100644 --- a/commands/msg/msg.go +++ b/commands/msg/msg.go @@ -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) } diff --git a/commands/msg/read.go b/commands/msg/read.go index 98447979..db463f18 100644 --- a/commands/msg/read.go +++ b/commands/msg/read.go @@ -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) Aliases() []string { + return []string{"read", "unread"} +} + +func (_ Read) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func Read(aerc *widgets.Aerc, args []string) error { +func (_ Read) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: " + args[0]) } diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 51f65841..7a64d21e 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -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) Aliases() []string { + return []string{"reply", "forward"} +} + +func (_ reply) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func Reply(aerc *widgets.Aerc, args []string) error { +func (_ reply) Execute(aerc *widgets.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args, "aq") if err != nil { return err |