From 9c3f12379b34dd86b1208a8aa6e1e458b4f883c5 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Wed, 10 May 2023 23:56:29 +0200 Subject: 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 Acked-by: Robin Jarry --- commands/msgview/save.go | 17 +++++++++-------- 1 file 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 } -- cgit