diff options
Diffstat (limited to 'commands/msg')
-rw-r--r-- | commands/msg/archive.go | 7 | ||||
-rw-r--r-- | commands/msg/copy.go | 6 | ||||
-rw-r--r-- | commands/msg/delete.go | 4 | ||||
-rw-r--r-- | commands/msg/envelope.go | 4 | ||||
-rw-r--r-- | commands/msg/fold.go | 4 | ||||
-rw-r--r-- | commands/msg/forward.go | 7 | ||||
-rw-r--r-- | commands/msg/invite.go | 4 | ||||
-rw-r--r-- | commands/msg/mark.go | 4 | ||||
-rw-r--r-- | commands/msg/modify-labels.go | 6 | ||||
-rw-r--r-- | commands/msg/move.go | 6 | ||||
-rw-r--r-- | commands/msg/pipe.go | 4 | ||||
-rw-r--r-- | commands/msg/read.go | 13 | ||||
-rw-r--r-- | commands/msg/recall.go | 4 | ||||
-rw-r--r-- | commands/msg/reply.go | 7 | ||||
-rw-r--r-- | commands/msg/toggle-thread-context.go | 4 | ||||
-rw-r--r-- | commands/msg/toggle-threads.go | 4 | ||||
-rw-r--r-- | commands/msg/unsubscribe.go | 5 |
17 files changed, 28 insertions, 65 deletions
diff --git a/commands/msg/archive.go b/commands/msg/archive.go index f4d6e3be..34cba8b8 100644 --- a/commands/msg/archive.go +++ b/commands/msg/archive.go @@ -21,7 +21,7 @@ const ( var ARCHIVE_TYPES = []string{ARCHIVE_FLAT, ARCHIVE_YEAR, ARCHIVE_MONTH} type Archive struct { - Type string `opt:"type" action:"ParseArchiveType" metavar:"flat|year|month"` + Type string `opt:"type" action:"ParseArchiveType" metavar:"flat|year|month" complete:"CompleteType"` } func (a *Archive) ParseArchiveType(arg string) error { @@ -42,9 +42,8 @@ func (Archive) Aliases() []string { return []string{"archive"} } -func (Archive) Complete(args []string) []string { - valid := []string{"flat", "year", "month"} - return commands.CompletionFromList(valid, args) +func (*Archive) CompleteType(arg string) []string { + return commands.CompletionFromList(ARCHIVE_TYPES, arg) } func (a Archive) Execute(args []string) error { diff --git a/commands/msg/copy.go b/commands/msg/copy.go index 4109ef99..77c9ade1 100644 --- a/commands/msg/copy.go +++ b/commands/msg/copy.go @@ -10,7 +10,7 @@ import ( type Copy struct { CreateFolders bool `opt:"-p"` - Folder string `opt:"..." metavar:"<folder>"` + Folder string `opt:"folder" complete:"CompleteFolder"` } func init() { @@ -21,8 +21,8 @@ func (Copy) Aliases() []string { return []string{"cp", "copy"} } -func (Copy) Complete(args []string) []string { - return commands.GetFolders(args) +func (*Copy) CompleteFolder(arg string) []string { + return commands.GetFolders(arg) } func (c Copy) Execute(args []string) error { diff --git a/commands/msg/delete.go b/commands/msg/delete.go index 49463abc..1a1a130c 100644 --- a/commands/msg/delete.go +++ b/commands/msg/delete.go @@ -21,10 +21,6 @@ func (Delete) Aliases() []string { return []string{"delete", "delete-message"} } -func (Delete) Complete(args []string) []string { - return nil -} - func (Delete) Execute(args []string) error { h := newHelper() store, err := h.store() diff --git a/commands/msg/envelope.go b/commands/msg/envelope.go index 6da82a1e..e104648d 100644 --- a/commands/msg/envelope.go +++ b/commands/msg/envelope.go @@ -25,10 +25,6 @@ func (Envelope) Aliases() []string { return []string{"envelope"} } -func (Envelope) Complete(args []string) []string { - return nil -} - func (e Envelope) Execute(args []string) error { acct := app.SelectedAccount() if acct == nil { diff --git a/commands/msg/fold.go b/commands/msg/fold.go index 0621c8c3..06e933d7 100644 --- a/commands/msg/fold.go +++ b/commands/msg/fold.go @@ -17,10 +17,6 @@ func (Fold) Aliases() []string { return []string{"fold", "unfold"} } -func (Fold) Complete(args []string) []string { - return nil -} - func (Fold) Execute(args []string) error { h := newHelper() store, err := h.store() diff --git a/commands/msg/forward.go b/commands/msg/forward.go index e6e386a9..4147e8c7 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -13,6 +13,7 @@ import ( "sync" "git.sr.ht/~rjarry/aerc/app" + "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/format" @@ -27,7 +28,7 @@ type forward struct { AttachFull bool `opt:"-F"` Edit bool `opt:"-e"` NoEdit bool `opt:"-E"` - Template string `opt:"-T"` + Template string `opt:"-T" complete:"CompleteTemplate"` To []string `opt:"..." required:"false"` } @@ -39,8 +40,8 @@ func (forward) Aliases() []string { return []string{"forward"} } -func (forward) Complete(args []string) []string { - return nil +func (*forward) CompleteTemplate(arg string) []string { + return commands.GetTemplates(arg) } func (f forward) Execute(args []string) error { diff --git a/commands/msg/invite.go b/commands/msg/invite.go index 5b8558b0..12bea93e 100644 --- a/commands/msg/invite.go +++ b/commands/msg/invite.go @@ -28,10 +28,6 @@ func (invite) Aliases() []string { return []string{"accept", "accept-tentative", "decline"} } -func (invite) Complete(args []string) []string { - return nil -} - func (i invite) Execute(args []string) error { acct := app.SelectedAccount() if acct == nil { diff --git a/commands/msg/mark.go b/commands/msg/mark.go index c2c21cf2..9547548f 100644 --- a/commands/msg/mark.go +++ b/commands/msg/mark.go @@ -20,10 +20,6 @@ func (Mark) Aliases() []string { return []string{"mark", "unmark", "remark"} } -func (Mark) Complete(args []string) []string { - return nil -} - func (m Mark) Execute(args []string) error { h := newHelper() OnSelectedMessage := func(fn func(uint32)) error { diff --git a/commands/msg/modify-labels.go b/commands/msg/modify-labels.go index 6fdbeac4..8cc72f2a 100644 --- a/commands/msg/modify-labels.go +++ b/commands/msg/modify-labels.go @@ -9,7 +9,7 @@ import ( ) type ModifyLabels struct { - Labels []string `opt:"..." metavar:"[+-]<label>"` + Labels []string `opt:"..." metavar:"[+-]<label>" complete:"CompleteLabels"` } func init() { @@ -20,8 +20,8 @@ func (ModifyLabels) Aliases() []string { return []string{"modify-labels", "tag"} } -func (ModifyLabels) Complete(args []string) []string { - return commands.GetLabels(args) +func (*ModifyLabels) CompleteLabels(arg string) []string { + return commands.GetLabels(arg) } func (m ModifyLabels) Execute(args []string) error { diff --git a/commands/msg/move.go b/commands/msg/move.go index 1dd68d35..06c7fc15 100644 --- a/commands/msg/move.go +++ b/commands/msg/move.go @@ -14,7 +14,7 @@ import ( type Move struct { CreateFolders bool `opt:"-p"` - Folder string `opt:"..." metavar:"<folder>"` + Folder string `opt:"folder" complete:"CompleteFolder"` } func init() { @@ -25,8 +25,8 @@ func (Move) Aliases() []string { return []string{"mv", "move"} } -func (Move) Complete(args []string) []string { - return commands.GetFolders(args) +func (*Move) CompleteFolder(arg string) []string { + return commands.GetFolders(arg) } func (m Move) Execute(args []string) error { diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go index b984752b..b32d7159 100644 --- a/commands/msg/pipe.go +++ b/commands/msg/pipe.go @@ -32,10 +32,6 @@ func (Pipe) Aliases() []string { return []string{"pipe"} } -func (Pipe) Complete(args []string) []string { - return nil -} - func (p Pipe) Execute(args []string) error { if p.Full && p.Part { return errors.New("-m and -p are mutually exclusive") diff --git a/commands/msg/read.go b/commands/msg/read.go index e55ed00e..72159a53 100644 --- a/commands/msg/read.go +++ b/commands/msg/read.go @@ -6,6 +6,7 @@ import ( "time" "git.sr.ht/~rjarry/aerc/app" + "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -13,7 +14,7 @@ import ( type FlagMsg struct { Toggle bool `opt:"-t"` Answered bool `opt:"-a" aliases:"flag,unflag"` - Flag models.Flags `opt:"-x" aliases:"flag,unflag" action:"ParseFlag"` + Flag models.Flags `opt:"-x" aliases:"flag,unflag" action:"ParseFlag" complete:"CompleteFlag"` FlagName string } @@ -25,10 +26,6 @@ func (FlagMsg) Aliases() []string { return []string{"flag", "unflag", "read", "unread"} } -func (FlagMsg) Complete(args []string) []string { - return nil -} - func (f *FlagMsg) ParseFlag(arg string) error { switch strings.ToLower(arg) { case "seen": @@ -46,6 +43,12 @@ func (f *FlagMsg) ParseFlag(arg string) error { return nil } +var validFlags = []string{"seen", "answered", "flagged"} + +func (*FlagMsg) CompleteFlag(arg string) []string { + return commands.CompletionFromList(validFlags, arg) +} + // If this was called as 'flag' or 'unflag', without the toggle (-t) // option, then it will flag the corresponding messages with the given // flag. If the toggle option was given, it will individually toggle diff --git a/commands/msg/recall.go b/commands/msg/recall.go index 3b78a763..cea02ddb 100644 --- a/commands/msg/recall.go +++ b/commands/msg/recall.go @@ -31,10 +31,6 @@ func (Recall) Aliases() []string { return []string{"recall"} } -func (Recall) Complete(args []string) []string { - return nil -} - func (r Recall) Execute(args []string) error { editHeaders := (config.Compose.EditHeaders || r.Edit) && !r.NoEdit diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 2ab9e9f8..ebf20317 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -10,6 +10,7 @@ import ( "time" "git.sr.ht/~rjarry/aerc/app" + "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/commands/account" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" @@ -26,7 +27,7 @@ type reply struct { All bool `opt:"-a"` Close bool `opt:"-c"` Quote bool `opt:"-q"` - Template string `opt:"-T"` + Template string `opt:"-T" complete:"CompleteTemplate"` Edit bool `opt:"-e"` NoEdit bool `opt:"-E"` } @@ -39,8 +40,8 @@ func (reply) Aliases() []string { return []string{"reply"} } -func (reply) Complete(args []string) []string { - return nil +func (*reply) CompleteTemplate(arg string) []string { + return commands.GetTemplates(arg) } func (r reply) Execute(args []string) error { diff --git a/commands/msg/toggle-thread-context.go b/commands/msg/toggle-thread-context.go index 0ef6778f..4b87eaa8 100644 --- a/commands/msg/toggle-thread-context.go +++ b/commands/msg/toggle-thread-context.go @@ -14,10 +14,6 @@ func (ToggleThreadContext) Aliases() []string { return []string{"toggle-thread-context"} } -func (ToggleThreadContext) Complete(args []string) []string { - return nil -} - func (ToggleThreadContext) Execute(args []string) error { h := newHelper() store, err := h.store() diff --git a/commands/msg/toggle-threads.go b/commands/msg/toggle-threads.go index 88cc763f..d2933bba 100644 --- a/commands/msg/toggle-threads.go +++ b/commands/msg/toggle-threads.go @@ -15,10 +15,6 @@ func (ToggleThreads) Aliases() []string { return []string{"toggle-threads"} } -func (ToggleThreads) Complete(args []string) []string { - return nil -} - func (ToggleThreads) Execute(args []string) error { h := newHelper() acct, err := h.account() diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go index 6fef16f5..c6a0b23f 100644 --- a/commands/msg/unsubscribe.go +++ b/commands/msg/unsubscribe.go @@ -31,11 +31,6 @@ func (Unsubscribe) Aliases() []string { return []string{"unsubscribe"} } -// Complete returns a list of completions -func (Unsubscribe) Complete(args []string) []string { - return nil -} - // Execute runs the Unsubscribe command func (u Unsubscribe) Execute(args []string) error { editHeaders := (config.Compose.EditHeaders || u.Edit) && !u.NoEdit |