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/compose | |
parent | 177651bddab145c8a56cdfeb0d57b5fd95a6d0e2 (diff) | |
download | aerc-2a0961701c4cabecc53d134ed1782e5612e64580.zip |
Implement basic tab completion support
Tab completion currently only works on commands. Contextual completion
will be added in the future.
Diffstat (limited to 'commands/compose')
-rw-r--r-- | commands/compose/abort.go | 14 | ||||
-rw-r--r-- | commands/compose/compose.go | 4 | ||||
-rw-r--r-- | commands/compose/edit.go | 14 | ||||
-rw-r--r-- | commands/compose/next-field.go | 19 | ||||
-rw-r--r-- | commands/compose/send.go | 16 |
5 files changed, 53 insertions, 14 deletions
diff --git a/commands/compose/abort.go b/commands/compose/abort.go index c60793c..4c121d7 100644 --- a/commands/compose/abort.go +++ b/commands/compose/abort.go @@ -6,11 +6,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type Abort struct{} + func init() { - register("abort", CommandAbort) + register(Abort{}) +} + +func (_ Abort) Aliases() []string { + return []string{"abort"} +} + +func (_ Abort) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func CommandAbort(aerc *widgets.Aerc, args []string) error { +func (_ Abort) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: abort") } diff --git a/commands/compose/compose.go b/commands/compose/compose.go index 35a2ed7..d61696e 100644 --- a/commands/compose/compose.go +++ b/commands/compose/compose.go @@ -8,9 +8,9 @@ var ( ComposeCommands *commands.Commands ) -func register(name string, cmd commands.AercCommand) { +func register(cmd commands.Command) { if ComposeCommands == nil { ComposeCommands = commands.NewCommands() } - ComposeCommands.Register(name, cmd) + ComposeCommands.Register(cmd) } diff --git a/commands/compose/edit.go b/commands/compose/edit.go index 18ba481..e888350 100644 --- a/commands/compose/edit.go +++ b/commands/compose/edit.go @@ -6,11 +6,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type Edit struct{} + func init() { - register("edit", CommandEdit) + register(Edit{}) +} + +func (_ Edit) Aliases() []string { + return []string{"edit"} +} + +func (_ Edit) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func CommandEdit(aerc *widgets.Aerc, args []string) error { +func (_ Edit) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: edit") } diff --git a/commands/compose/next-field.go b/commands/compose/next-field.go index a10aa32..3496dfd 100644 --- a/commands/compose/next-field.go +++ b/commands/compose/next-field.go @@ -7,16 +7,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type NextPrevField struct{} + func init() { - register("next-field", NextPrevField) - register("prev-field", NextPrevField) + register(NextPrevField{}) } -func nextPrevFieldUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s", cmd)) +func (_ NextPrevField) Aliases() []string { + return []string{"next-field", "prev-field"} +} + +func (_ NextPrevField) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func NextPrevField(aerc *widgets.Aerc, args []string) error { +func (_ NextPrevField) Execute(aerc *widgets.Aerc, args []string) error { if len(args) > 2 { return nextPrevFieldUsage(args[0]) } @@ -28,3 +33,7 @@ func NextPrevField(aerc *widgets.Aerc, args []string) error { } return nil } + +func nextPrevFieldUsage(cmd string) error { + return errors.New(fmt.Sprintf("Usage: %s", cmd)) +} diff --git a/commands/compose/send.go b/commands/compose/send.go index c4bff11..26df82a 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -20,13 +20,23 @@ import ( "git.sr.ht/~sircmpwn/aerc/worker/types" ) +type Send struct{} + func init() { - register("send", SendMessage) + register(Send{}) +} + +func (_ Send) Aliases() []string { + return []string{"send"} +} + +func (_ Send) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func SendMessage(aerc *widgets.Aerc, args []string) error { +func (_ Send) Execute(aerc *widgets.Aerc, args []string) error { if len(args) > 1 { - return errors.New("Usage: send-message") + return errors.New("Usage: send") } composer, _ := aerc.SelectedTab().(*widgets.Composer) config := composer.Config() |