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/account | |
parent | 177651bddab145c8a56cdfeb0d57b5fd95a6d0e2 (diff) |
Implement basic tab completion support
Tab completion currently only works on commands. Contextual completion
will be added in the future.
Diffstat (limited to 'commands/account')
-rw-r--r-- | commands/account/account.go | 4 | ||||
-rw-r--r-- | commands/account/cf.go | 14 | ||||
-rw-r--r-- | commands/account/compose.go | 14 | ||||
-rw-r--r-- | commands/account/mkdir.go | 14 | ||||
-rw-r--r-- | commands/account/next-folder.go | 19 | ||||
-rw-r--r-- | commands/account/next-result.go | 19 | ||||
-rw-r--r-- | commands/account/next.go | 21 | ||||
-rw-r--r-- | commands/account/pipe.go | 14 | ||||
-rw-r--r-- | commands/account/search.go | 15 | ||||
-rw-r--r-- | commands/account/select.go | 15 | ||||
-rw-r--r-- | commands/account/view.go | 15 |
11 files changed, 128 insertions, 36 deletions
diff --git a/commands/account/account.go b/commands/account/account.go index c590c8a..9c90087 100644 --- a/commands/account/account.go +++ b/commands/account/account.go @@ -8,9 +8,9 @@ var ( AccountCommands *commands.Commands ) -func register(name string, cmd commands.AercCommand) { +func register(cmd commands.Command) { if AccountCommands == nil { AccountCommands = commands.NewCommands() } - AccountCommands.Register(name, cmd) + AccountCommands.Register(cmd) } diff --git a/commands/account/cf.go b/commands/account/cf.go index 2816473..197e956 100644 --- a/commands/account/cf.go +++ b/commands/account/cf.go @@ -10,12 +10,22 @@ var ( history map[string]string ) +type ChangeFolder struct{} + func init() { history = make(map[string]string) - register("cf", ChangeFolder) + register(ChangeFolder{}) +} + +func (_ ChangeFolder) Aliases() []string { + return []string{"cf"} +} + +func (_ ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func ChangeFolder(aerc *widgets.Aerc, args []string) error { +func (_ ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 2 { return errors.New("Usage: cf <folder>") } diff --git a/commands/account/compose.go b/commands/account/compose.go index aeb415e..cafba78 100644 --- a/commands/account/compose.go +++ b/commands/account/compose.go @@ -6,12 +6,22 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type Compose struct{} + func init() { - register("compose", Compose) + register(Compose{}) +} + +func (_ Compose) Aliases() []string { + return []string{"compose"} +} + +func (_ Compose) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } // TODO: Accept arguments for default headers, message body -func Compose(aerc *widgets.Aerc, args []string) error { +func (_ Compose) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: compose") } diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go index d245821..be9b14a 100644 --- a/commands/account/mkdir.go +++ b/commands/account/mkdir.go @@ -10,11 +10,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/worker/types" ) +type MakeDir struct{} + func init() { - register("mkdir", Mkdir) + register(MakeDir{}) +} + +func (_ MakeDir) Aliases() []string { + return []string{"mkdir"} +} + +func (_ MakeDir) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func Mkdir(aerc *widgets.Aerc, args []string) error { +func (_ MakeDir) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 2 { return errors.New("Usage: :mkdir <name>") } diff --git a/commands/account/next-folder.go b/commands/account/next-folder.go index 6ad3d54..414e606 100644 --- a/commands/account/next-folder.go +++ b/commands/account/next-folder.go @@ -8,16 +8,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type NextPrevFolder struct{} + func init() { - register("next-folder", NextPrevFolder) - register("prev-folder", NextPrevFolder) + register(NextPrevFolder{}) } -func nextPrevFolderUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [n]", cmd)) +func (_ NextPrevFolder) Aliases() []string { + return []string{"next-folder", "prev-folder"} +} + +func (_ NextPrevFolder) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func NextPrevFolder(aerc *widgets.Aerc, args []string) error { +func (_ NextPrevFolder) Execute(aerc *widgets.Aerc, args []string) error { if len(args) > 2 { return nextPrevFolderUsage(args[0]) } @@ -44,3 +49,7 @@ func NextPrevFolder(aerc *widgets.Aerc, args []string) error { } return nil } + +func nextPrevFolderUsage(cmd string) error { + return errors.New(fmt.Sprintf("Usage: %s [n]", cmd)) +} diff --git a/commands/account/next-result.go b/commands/account/next-result.go index d89de56..24d53be 100644 --- a/commands/account/next-result.go +++ b/commands/account/next-result.go @@ -7,16 +7,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type NextPrevResult struct{} + func init() { - register("next-result", NextPrevResult) - register("prev-result", NextPrevResult) + register(NextPrevResult{}) } -func nextPrevResultUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd)) +func (_ NextPrevResult) Aliases() []string { + return []string{"next-result", "prev-result"} +} + +func (_ NextPrevResult) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func NextPrevResult(aerc *widgets.Aerc, args []string) error { +func (_ NextPrevResult) Execute(aerc *widgets.Aerc, args []string) error { if len(args) > 1 { return nextPrevResultUsage(args[0]) } @@ -39,3 +44,7 @@ func NextPrevResult(aerc *widgets.Aerc, args []string) error { } return nil } + +func nextPrevResultUsage(cmd string) error { + return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd)) +} diff --git a/commands/account/next.go b/commands/account/next.go index 3b9260c..f306b48 100644 --- a/commands/account/next.go +++ b/commands/account/next.go @@ -9,18 +9,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type NextPrevMsg struct{} + func init() { - register("next", NextPrevMessage) - register("next-message", NextPrevMessage) - register("prev", NextPrevMessage) - register("prev-message", NextPrevMessage) + register(NextPrevMsg{}) } -func nextPrevMessageUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd)) +func (_ NextPrevMsg) Aliases() []string { + return []string{"next", "next-message", "prev", "prev-message"} +} + +func (_ NextPrevMsg) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func NextPrevMessage(aerc *widgets.Aerc, args []string) error { +func (_ NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error { if len(args) > 2 { return nextPrevMessageUsage(args[0]) } @@ -63,3 +66,7 @@ func NextPrevMessage(aerc *widgets.Aerc, args []string) error { } return nil } + +func nextPrevMessageUsage(cmd string) error { + return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd)) +} diff --git a/commands/account/pipe.go b/commands/account/pipe.go index d3cc80a..a68ef64 100644 --- a/commands/account/pipe.go +++ b/commands/account/pipe.go @@ -8,11 +8,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type Pipe struct{} + func init() { - register("pipe", Pipe) + register(Pipe{}) +} + +func (_ Pipe) Aliases() []string { + return []string{"pipe"} +} + +func (_ Pipe) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func Pipe(aerc *widgets.Aerc, args []string) error { +func (_ Pipe) Execute(aerc *widgets.Aerc, args []string) error { if len(args) < 2 { return errors.New("Usage: :pipe <cmd> [args...]") } diff --git a/commands/account/search.go b/commands/account/search.go index 513ad43..a8640dc 100644 --- a/commands/account/search.go +++ b/commands/account/search.go @@ -9,12 +9,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type SearchFilter struct{} + func init() { - register("search", SearchFilter) - //register("filter", SearchFilter) // TODO + register(SearchFilter{}) +} + +func (_ SearchFilter) Aliases() []string { + return []string{"search"} +} + +func (_ SearchFilter) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func SearchFilter(aerc *widgets.Aerc, args []string) error { +func (_ SearchFilter) Execute(aerc *widgets.Aerc, args []string) error { var ( criteria *imap.SearchCriteria = imap.NewSearchCriteria() ) diff --git a/commands/account/select.go b/commands/account/select.go index 707f6c9..70e08ac 100644 --- a/commands/account/select.go +++ b/commands/account/select.go @@ -7,12 +7,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type SelectMessage struct{} + func init() { - register("select", SelectMessage) - register("select-message", SelectMessage) + register(SelectMessage{}) +} + +func (_ SelectMessage) Aliases() []string { + return []string{"select", "select-message"} +} + +func (_ SelectMessage) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func SelectMessage(aerc *widgets.Aerc, args []string) error { +func (_ SelectMessage) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 2 { return errors.New("Usage: :select-message <n>") } diff --git a/commands/account/view.go b/commands/account/view.go index f7f3ec6..cec65aa 100644 --- a/commands/account/view.go +++ b/commands/account/view.go @@ -6,12 +6,21 @@ import ( "git.sr.ht/~sircmpwn/aerc/widgets" ) +type ViewMessage struct{} + func init() { - register("view", ViewMessage) - register("view-message", ViewMessage) + register(ViewMessage{}) +} + +func (_ ViewMessage) Aliases() []string { + return []string{"view-message", "view"} +} + +func (_ ViewMessage) Complete(aerc *widgets.Aerc, args []string) []string { + return nil } -func ViewMessage(aerc *widgets.Aerc, args []string) error { +func (_ ViewMessage) Execute(aerc *widgets.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: view-message") } |