aboutsummaryrefslogtreecommitdiffstats
path: root/commands/account/mkdir.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/account/mkdir.go')
-rw-r--r--commands/account/mkdir.go29
1 files changed, 9 insertions, 20 deletions
diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go
index 9beeb01a..3e546ace 100644
--- a/commands/account/mkdir.go
+++ b/commands/account/mkdir.go
@@ -2,15 +2,15 @@ package account
import (
"errors"
- "strings"
"time"
"git.sr.ht/~rjarry/aerc/app"
+ "git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/worker/types"
)
type MakeDir struct {
- Folder string `opt:"..." metavar:"<folder>"`
+ Folder string `opt:"folder" complete:"CompleteFolder"`
}
func init() {
@@ -21,26 +21,15 @@ func (MakeDir) Aliases() []string {
return []string{"mkdir"}
}
-func (MakeDir) Complete(args []string) []string {
- if len(args) == 0 {
+func (*MakeDir) CompleteFolder(arg string) []string {
+ acct := app.SelectedAccount()
+ if acct == nil {
return nil
}
- name := strings.Join(args, " ")
-
- list := app.SelectedAccount().Directories().List()
- inboxes := make([]string, len(list))
- copy(inboxes, list)
-
- // remove inboxes that don't match and append the path separator to all
- // others
- for i := len(inboxes) - 1; i >= 0; i-- {
- if !strings.HasPrefix(inboxes[i], name) && name != "" {
- inboxes = append(inboxes[:i], inboxes[i+1:]...)
- continue
- }
- inboxes[i] += app.SelectedAccount().Worker().PathSeparator()
- }
- return inboxes
+ return commands.FilterList(
+ acct.Directories().List(), arg, "",
+ app.SelectedAccount().Worker().PathSeparator(),
+ app.SelectedAccountUiConfig().FuzzyComplete)
}
func (m MakeDir) Execute(args []string) error {