Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Nov 19, 2022
1 parent dc9bd25 commit 3ad024d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion traverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package carapace
import (
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/internal/pflagfork"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand All @@ -20,7 +21,8 @@ func (f InFlag) Consumes(arg string) bool {
}

func actionTraverse(c *cobra.Command, args []string) (Action, Context) {
// TODO PreInvoke
preInvoke(c, args)

inArgs := []string{} // args consumed by current command
var inFlag *InFlag
fs := pflagfork.FlagSet(c.Flags())
Expand Down Expand Up @@ -88,4 +90,10 @@ func actionTraverse(c *cobra.Command, args []string) (Action, Context) {
func subcommand(cmd *cobra.Command, arg string) (subcommand *cobra.Command) {
subcommand, _, _ = cmd.Find([]string{arg})
return
}

func preInvoke(cmd *cobra.Command, args []string) {
if subCmd := subcommand(cmd, "_carapace"); subCmd != nil && subCmd.PreRun != nil {
subCmd.PreRun(cmd, args)
}
}

0 comments on commit 3ad024d

Please sign in to comment.