From abe228b14d97d8d47e8ff4406de387fac45cfe68 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sun, 22 Oct 2023 23:23:18 +0200 Subject: commands: use completion from go-opt Implement command completion with complete struct field tags from the get-opt library introduced earlier. Changelog-changed: Improved command completion. Signed-off-by: Robin Jarry Reviewed-by: Koni Marti Tested-by: Moritz Poldrack Tested-by: Inwit --- commands/compose/postpone.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'commands/compose/postpone.go') diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go index 767e759c..3ce9cc84 100644 --- a/commands/compose/postpone.go +++ b/commands/compose/postpone.go @@ -14,7 +14,7 @@ import ( ) type Postpone struct { - Folder string `opt:"-t"` + Folder string `opt:"-t" complete:"CompleteFolder"` } func init() { @@ -25,20 +25,8 @@ func (Postpone) Aliases() []string { return []string{"postpone"} } -func (Postpone) Options() string { - return "t:" -} - -func (Postpone) CompleteOption(r rune, arg string) []string { - var valid []string - if r == 't' { - valid = commands.GetFolders([]string{arg}) - } - return commands.CompletionFromList(valid, []string{arg}) -} - -func (Postpone) Complete(args []string) []string { - return nil +func (*Postpone) CompleteFolder(arg string) []string { + return commands.GetFolders(arg) } func (p Postpone) Execute(args []string) error { -- cgit