aboutsummaryrefslogtreecommitdiff
path: root/commands/account/cf.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/account/cf.go')
-rw-r--r--commands/account/cf.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/commands/account/cf.go b/commands/account/cf.go
index f0fa3b67..09d2e523 100644
--- a/commands/account/cf.go
+++ b/commands/account/cf.go
@@ -2,7 +2,6 @@ package account
import (
"errors"
- "strings"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib/state"
@@ -11,7 +10,9 @@ import (
var history map[string]string
-type ChangeFolder struct{}
+type ChangeFolder struct {
+ Folder string `opt:"..."`
+}
func init() {
history = make(map[string]string)
@@ -26,24 +27,21 @@ func (ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string {
return commands.GetFolders(aerc, args)
}
-func (ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error {
- if len(args) == 1 {
- return errors.New("Usage: cf <folder>")
- }
+func (c ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error {
acct := aerc.SelectedAccount()
if acct == nil {
return errors.New("No account selected")
}
previous := acct.Directories().Selected()
- joinedArgs := strings.Join(args[1:], " ")
- if joinedArgs == "-" {
+
+ if c.Folder == "-" {
if dir, ok := history[acct.Name()]; ok {
acct.Directories().Select(dir)
} else {
return errors.New("No previous folder to return to")
}
} else {
- acct.Directories().Select(joinedArgs)
+ acct.Directories().Select(c.Folder)
}
history[acct.Name()] = previous