diff options
author | Robin Jarry <robin@jarry.cc> | 2023-10-22 23:23:18 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-28 19:25:10 +0200 |
commit | abe228b14d97d8d47e8ff4406de387fac45cfe68 (patch) | |
tree | 56117403d1ae32d7253f86bab01a944a3cf225b9 /commands/cd.go | |
parent | 30851656591293ed2e19340ab78c937855a11143 (diff) | |
download | aerc-abe228b14d97d8d47e8ff4406de387fac45cfe68.tar.gz |
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 <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'commands/cd.go')
-rw-r--r-- | commands/cd.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/commands/cd.go b/commands/cd.go index 6620e732..d2dc5310 100644 --- a/commands/cd.go +++ b/commands/cd.go @@ -12,7 +12,7 @@ import ( var previousDir string type ChangeDirectory struct { - Target string `opt:"directory" default:"~"` + Target string `opt:"directory" default:"~" complete:"CompleteTarget"` } func init() { @@ -23,9 +23,8 @@ func (ChangeDirectory) Aliases() []string { return []string{"cd"} } -func (ChangeDirectory) Complete(args []string) []string { - path := strings.Join(args, " ") - completions := CompletePath(path) +func (*ChangeDirectory) CompleteTarget(arg string) []string { + completions := CompletePath(arg) var dirs []string for _, c := range completions { |