Skip to content

Commit bfb2f82

Browse files
committed
pixi: added preinvoke
1 parent 06e5e3b commit bfb2f82

File tree

1 file changed

+12
-0
lines changed
  • completers/common/pixi_completer/cmd

1 file changed

+12
-0
lines changed

completers/common/pixi_completer/cmd/root.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"github.com/carapace-sh/carapace"
55
"github.com/spf13/cobra"
6+
"github.com/spf13/pflag"
67
)
78

89
var rootCmd = &cobra.Command{
@@ -30,4 +31,15 @@ func init() {
3031
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
3132
"color": carapace.ActionValues("always", "never", "auto"),
3233
})
34+
35+
carapace.Gen(rootCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action {
36+
// TODO handle PIXI_PROJECT_ROOT
37+
if f := cmd.Flag("manifest-path"); f != nil && f.Changed {
38+
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
39+
c.Setenv("PIXI_PROJECT_MANIFEST", f.Value.String())
40+
return action.Invoke(c).ToA()
41+
})
42+
}
43+
return action
44+
})
3345
}

0 commit comments

Comments
 (0)