Skip to content

Commit

Permalink
go: run - positional directory completion
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Apr 30, 2024
1 parent 7cd4ec4 commit c316e3a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions completers/go_completer/cmd/run.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"strings"

"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
Expand All @@ -18,4 +20,13 @@ func init() {
runCmd.Flags().StringS("exec", "exec", "", "invoke the binary using xprog")
addBuildFlags(runCmd)
rootCmd.AddCommand(runCmd)

carapace.Gen(runCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if strings.HasPrefix(c.Value, ".") {
return carapace.ActionDirectories()
}
return carapace.ActionValues()
}),
)
}

0 comments on commit c316e3a

Please sign in to comment.