Skip to content

Commit

Permalink
go: doc - support relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Nov 29, 2023
1 parent 8be2218 commit 04960bf
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 04960bf

Please sign in to comment.