aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-05-10 23:56:29 +0200
committerRobin Jarry <robin@jarry.cc>2023-05-16 13:41:30 +0200
commit9c3f12379b34dd86b1208a8aa6e1e458b4f883c5 (patch)
tree45e8431a2b7a145669aec07211a4386a5e61063e
parentd04387c4ed2d118d6041594fe9086db29bdd2448 (diff)
downloadaerc-9c3f12379b34dd86b1208a8aa6e1e458b4f883c5.tar.gz
aerc-9c3f12379b34dd86b1208a8aa6e1e458b4f883c5.zip
save: update completion
Use the updated completion and avoid removing flag when completing paths. Fixes: https://todo.sr.ht/~rjarry/aerc/110 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--commands/msgview/save.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index ef31988b..7d82ff95 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -25,16 +25,17 @@ func init() {
register(Save{})
}
+func (Save) Options() string {
+ return "fpa"
+}
+
func (Save) Aliases() []string {
return []string{"save"}
}
-func (Save) Complete(aerc *widgets.Aerc, args []string) []string {
- _, optind, _ := getopt.Getopts(args, "fpa")
- if optind < len(args) {
- args = args[optind:]
- }
- path := strings.Join(args, " ")
+func (s Save) Complete(aerc *widgets.Aerc, args []string) []string {
+ trimmed := commands.Operands(args, s.Options())
+ path := strings.Join(trimmed, " ")
defaultPath := config.General.DefaultSavePath
if defaultPath != "" && !isAbsPath(path) {
path = filepath.Join(defaultPath, path)
@@ -50,8 +51,8 @@ type saveParams struct {
attachments bool
}
-func (Save) Execute(aerc *widgets.Aerc, args []string) error {
- opts, optind, err := getopt.Getopts(args, "fpa")
+func (s Save) Execute(aerc *widgets.Aerc, args []string) error {
+ opts, optind, err := getopt.Getopts(args, s.Options())
if err != nil {
return err
}