Skip to content

Commit

Permalink
Merge pull request #2045 from rsteube/go-doc-relativepath
Browse files Browse the repository at this point in the history
go: doc - support relative paths
  • Loading branch information
rsteube authored Nov 29, 2023
2 parents 8be2218 + 04960bf commit 6014a07
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion completers/go-tool-doc_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6014a07

Please sign in to comment.