diff options
author | Vitaly Ovchinnikov <v@postbox.nz> | 2023-08-12 10:22:46 +0300 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-08-25 14:08:09 +0200 |
commit | b919c0451c03e785c31eeea3a3b18b76492b6504 (patch) | |
tree | ef16feffbdf1e9d289c97a1e395de14bef78f7d5 /commands/account | |
parent | 91a8535a190137b4b6451658274acfefa6660847 (diff) | |
download | aerc-b919c0451c03e785c31eeea3a3b18b76492b6504.tar.gz |
export-mbox: better path suggestion and name completion
Change the `:export-mbox` path completion algorithm, so it works the
same as `:import-mbox`: the user can select folders with auto-complete,
the ~ symbol works as home folder and so on.
Move the automatic mbox-file naming into the export function and only
use it if the user-supplied path is an existing folder.
Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/account')
-rw-r--r-- | commands/account/export-mbox.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/commands/account/export-mbox.go b/commands/account/export-mbox.go index 1f4c5a42..8981261b 100644 --- a/commands/account/export-mbox.go +++ b/commands/account/export-mbox.go @@ -8,6 +8,7 @@ import ( "sync" "time" + "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/widgets" mboxer "git.sr.ht/~rjarry/aerc/worker/mbox" @@ -25,14 +26,7 @@ func (ExportMbox) Aliases() []string { } func (ExportMbox) Complete(aerc *widgets.Aerc, args []string) []string { - if acct := aerc.SelectedAccount(); acct != nil { - if path := acct.SelectedDirectory(); path != "" { - if f := filepath.Base(path); f != "" { - return []string{f + ".mbox"} - } - } - } - return nil + return commands.CompletePath(filepath.Join(args...)) } func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error { @@ -50,6 +44,15 @@ func (ExportMbox) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("No message store selected") } + fi, err := os.Stat(filename) + if err == nil && fi.IsDir() { + if path := acct.SelectedDirectory(); path != "" { + if f := filepath.Base(path); f != "" { + filename += f + ".mbox" + } + } + } + aerc.PushStatus("Exporting to "+filename, 10*time.Second) // uids of messages to export |