aboutsummaryrefslogtreecommitdiff
path: root/commands/account/import-mbox.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/account/import-mbox.go')
-rw-r--r--commands/account/import-mbox.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/commands/account/import-mbox.go b/commands/account/import-mbox.go
index 85e9a341..96f13888 100644
--- a/commands/account/import-mbox.go
+++ b/commands/account/import-mbox.go
@@ -18,7 +18,9 @@ import (
"git.sr.ht/~rjarry/aerc/worker/types"
)
-type ImportMbox struct{}
+type ImportMbox struct {
+ Filename string `opt:"FILENAME"`
+}
func init() {
register(ImportMbox{})
@@ -32,12 +34,7 @@ func (ImportMbox) Complete(aerc *widgets.Aerc, args []string) []string {
return commands.CompletePath(filepath.Join(args...))
}
-func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error {
- if len(args) != 2 {
- return importFolderUsage(args[0])
- }
- filename := args[1]
-
+func (i ImportMbox) Execute(aerc *widgets.Aerc, args []string) error {
acct := aerc.SelectedAccount()
if acct == nil {
return errors.New("No account selected")
@@ -54,10 +51,10 @@ func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error {
importFolder := func() {
defer log.PanicHandler()
- statusInfo := fmt.Sprintln("Importing", filename, "to folder", folder)
+ statusInfo := fmt.Sprintln("Importing", i.Filename, "to folder", folder)
aerc.PushStatus(statusInfo, 10*time.Second)
log.Debugf(statusInfo)
- f, err := os.Open(filename)
+ f, err := os.Open(i.Filename)
if err != nil {
aerc.PushError(err.Error())
return
@@ -148,7 +145,3 @@ func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error {
return nil
}
-
-func importFolderUsage(cmd string) error {
- return fmt.Errorf("Usage: %s <filename>", cmd)
-}