@@ -2,7 +2,9 @@ package cmd
22
33import (
44 "github.com/carapace-sh/carapace"
5+ "github.com/carapace-sh/carapace-bin/pkg/actions/tools/but"
56 "github.com/carapace-sh/carapace/pkg/traverse"
7+ "github.com/carapace-sh/carapace/pkg/util"
68 "github.com/spf13/cobra"
79 "github.com/spf13/pflag"
810)
@@ -22,9 +24,10 @@ func init() {
2224 carapace .Gen (rootCmd ).Standalone ()
2325
2426 rootCmd .AddGroup (
27+ & cobra.Group {ID : "inspection" },
2528 & cobra.Group {ID : "branching and committing" },
29+ & cobra.Group {ID : "server interactions" },
2630 & cobra.Group {ID : "editing commits" },
27- & cobra.Group {ID : "inspection" },
2831 & cobra.Group {ID : "operation history" },
2932 )
3033
@@ -40,7 +43,16 @@ func init() {
4043 })
4144
4245 carapace .Gen (rootCmd ).PositionalCompletion (
43- carapace .ActionDirectories (),
46+ carapace .Batch (
47+ but .ActionCliIds (but.CliIdsOpts {}.Default ()),
48+ carapace .ActionDirectories (),
49+ ).ToA (),
50+ carapace .ActionCallback (func (c carapace.Context ) carapace.Action {
51+ if util .HasPathPrefix (c .Args [0 ]) {
52+ return carapace .ActionValues ()
53+ }
54+ return but .ActionCliIds (but.CliIdsOpts {Branches : true , Stacks : true })
55+ }),
4456 )
4557
4658 carapace .Gen (rootCmd ).PreInvoke (func (cmd * cobra.Command , _ * pflag.Flag , action carapace.Action ) carapace.Action {
0 commit comments