Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 19, 2023
1 parent 918e2db commit 5b6d0ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cmd/carapace/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}),
)
}
3 changes: 3 additions & 0 deletions cmd/carapace/cmd/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ var scrapeCmd = &cobra.Command{
func init() {
carapace.Gen(scrapeCmd).Standalone()

carapace.Gen(scrapeCmd).PositionalCompletion(
carapace.ActionFiles(".yaml"),
)
}

0 comments on commit 5b6d0ce

Please sign in to comment.