diff --git a/cmd/carapace/cmd/run.go b/cmd/carapace/cmd/run.go index 619122dfc9..e6257a8236 100644 --- a/cmd/carapace/cmd/run.go +++ b/cmd/carapace/cmd/run.go @@ -5,14 +5,14 @@ import ( "os" "github.com/rsteube/carapace" + spec "github.com/rsteube/carapace-spec" "github.com/spf13/cobra" ) var runCmd = &cobra.Command{ - Use: "run", - Short: "", - Args: cobra.MinimumNArgs(1), - DisableFlagParsing: true, + Use: "run", + Short: "", + Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { _, spec, err := loadSpec(args[0]) if err != nil { @@ -29,5 +29,15 @@ var runCmd = &cobra.Command{ func init() { carapace.Gen(runCmd).Standalone() + runCmd.Flags().SetInterspersed(false) + carapace.Gen(runCmd).PositionalCompletion( + carapace.ActionFiles(".yaml"), + ) + + carapace.Gen(runCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + return spec.ActionSpec(c.Args[0]).Shift(1) // TODO + }), + ) } diff --git a/cmd/carapace/cmd/scrape.go b/cmd/carapace/cmd/scrape.go index 3e38718c61..c7970a317e 100644 --- a/cmd/carapace/cmd/scrape.go +++ b/cmd/carapace/cmd/scrape.go @@ -17,4 +17,7 @@ var scrapeCmd = &cobra.Command{ func init() { carapace.Gen(scrapeCmd).Standalone() + carapace.Gen(scrapeCmd).PositionalCompletion( + carapace.ActionFiles(".yaml"), + ) }