about summary refs log tree commit diff stats
path: root/commands/commands.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-04-11 04:12:38 +0200
committerDrew DeVault <sir@cmpwn.com>2020-04-11 10:46:46 -0400
commit1fbce012ed85f385be4add710c2de5bb09c81998 (patch)
treee5a8f8a9d0795d8c9764104a05c4bac8c78f353b /commands/commands.go
parent2b53347d0de8ca3b2bfdf539539dac01f7424678 (diff)
downloadaerc-1fbce012ed85f385be4add710c2de5bb09c81998.tar.gz
msg/archive: complete the possible options
Diffstat (limited to 'commands/commands.go')
-rw-r--r--commands/commands.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/commands/commands.go b/commands/commands.go
index 39720bf..0c761d1 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -128,6 +128,21 @@ func GetFolders(aerc *widgets.Aerc, args []string) []string {
 	return out
 }
 
+// CompletionFromList provides a convenience wrapper for commands to use in the
+// Complete function. It simply matches the items provided in valid
+func CompletionFromList(valid []string, args []string) []string {
+	out := make([]string, 0)
+	if len(args) == 0 {
+		return valid
+	}
+	for _, v := range valid {
+		if hasCaseSmartPrefix(v, args[0]) {
+			out = append(out, v)
+		}
+	}
+	return out
+}
+
 func GetLabels(aerc *widgets.Aerc, args []string) []string {
 	if len(args) == 0 {
 		return aerc.SelectedAccount().Labels()