Skip to content

Commit

Permalink
added yj
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 20, 2020
1 parent 3b0b7da commit 1995298
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions carapace/cmd/completers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import (
who "github.com/rsteube/carapace-bin/completers/who_completer/cmd"
whoami "github.com/rsteube/carapace-bin/completers/whoami_completer/cmd"
yes "github.com/rsteube/carapace-bin/completers/yes_completer/cmd"
yj "github.com/rsteube/carapace-bin/completers/yj_completer/cmd"
youtube_dl "github.com/rsteube/carapace-bin/completers/youtube-dl_completer/cmd"
)

Expand Down Expand Up @@ -195,6 +196,7 @@ var completers = []string{
"whoami",
"who",
"yes",
"yj",
"youtube-dl",
}

Expand Down Expand Up @@ -390,6 +392,8 @@ func executeCompleter(completer string) {
who.Execute()
case "yes":
yes.Execute()
case "yj":
yj.Execute()
case "youtube-dl":
youtube_dl.Execute()
}
Expand Down
40 changes: 40 additions & 0 deletions completers/yj_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "yj",
Short: "Convert between YAML, TOML, JSON, and HCL",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.Flags().BoolS("n", "n", false, "Do not covert inf, -inf, and NaN to/from strings (YAML or TOML only)")
rootCmd.Flags().BoolS("e", "e", false, "Escape HTML (JSON out only)")
rootCmd.Flags().BoolS("i", "i", false, "Indent output (JSON or TOML out only)")
rootCmd.Flags().BoolS("k", "k", false, "Attempt to parse keys as objects or numbers types (YAML out only)")
rootCmd.Flags().BoolS("h", "h", false, "Show this help message")
rootCmd.Flags().BoolS("v", "v", false, "Show version")

carapace.Gen(rootCmd).PositionalCompletion(
ActionFormats(),
ActionFormats(),
)
}

func ActionFormats() carapace.Action {
return carapace.ActionValuesDescribed(
"c", "HCL",
"j", "JSON",
"t", "TOML",
"y", "YAML",
)
}
7 changes: 7 additions & 0 deletions completers/yj_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/yj_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit 1995298

Please sign in to comment.