From 04960bf4a7f8c0b0965441213e9369c7465a65a9 Mon Sep 17 00:00:00 2001 From: rsteube Date: Wed, 29 Nov 2023 13:43:47 +0100 Subject: [PATCH] go: doc - support relative paths --- completers/go-tool-doc_completer/cmd/root.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/completers/go-tool-doc_completer/cmd/root.go b/completers/go-tool-doc_completer/cmd/root.go index 46f444fe02..4c3cbe0251 100644 --- a/completers/go-tool-doc_completer/cmd/root.go +++ b/completers/go-tool-doc_completer/cmd/root.go @@ -3,6 +3,7 @@ package cmd import ( "github.com/rsteube/carapace" "github.com/rsteube/carapace-bin/pkg/actions/tools/golang" + "github.com/rsteube/carapace/pkg/util" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -35,7 +36,12 @@ func init() { }) carapace.Gen(rootCmd).PositionalCompletion( - golang.ActionPackages(), + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if util.HasPathPrefix(c.Value) { + return carapace.ActionDirectories() + } + return golang.ActionPackages() + }), carapace.ActionMultiParts(".", func(c carapace.Context) carapace.Action { switch len(c.Parts) { case 0: