Skip to content

Commit

Permalink
added gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 17, 2020
1 parent 7bc8055 commit a6a85b3
Show file tree
Hide file tree
Showing 3 changed files with 44 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 @@ -32,6 +32,7 @@ import (
fmt "github.com/rsteube/carapace-bin/completers/fmt_completer/cmd"
fold "github.com/rsteube/carapace-bin/completers/fold_completer/cmd"
git "github.com/rsteube/carapace-bin/completers/git_completer/cmd"
gofmt "github.com/rsteube/carapace-bin/completers/gofmt_completer/cmd"
gradle "github.com/rsteube/carapace-bin/completers/gradle_completer/cmd"
grep "github.com/rsteube/carapace-bin/completers/grep_completer/cmd"
gunzip "github.com/rsteube/carapace-bin/completers/gunzip_completer/cmd"
Expand Down Expand Up @@ -130,6 +131,7 @@ var completers = []string{
"fmt",
"fold",
"git",
"gofmt",
"gradle",
"grep",
"gunzip",
Expand Down Expand Up @@ -260,6 +262,8 @@ func executeCompleter(completer string) {
fold.Execute()
case "git":
git.Execute()
case "gofmt":
gofmt.Execute()
case "gradle":
gradle.Execute()
case "grep":
Expand Down
33 changes: 33 additions & 0 deletions completers/gofmt_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

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

var rootCmd = &cobra.Command{
Use: "gofmt",
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

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

rootCmd.Flags().BoolS("w", "w", false, "write result to (source) file instead of stdout")
rootCmd.Flags().BoolS("d", "d", false, "display diffs instead of rewriting files")
rootCmd.Flags().BoolS("e", "e", false, "report all errors (not just the first 10 on different lines)")
rootCmd.Flags().BoolS("l", "l", false, "list files whose formatting differs from gofmt's")
rootCmd.Flags().StringS("r", "r", "", "rewrite rule")
rootCmd.Flags().BoolS("s", "s", false, "simplify code")
rootCmd.Flags().String("cpuprofile", "", "write cpu profile to this file")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"cpuprofile": carapace.ActionFiles(""),
})

carapace.Gen(rootCmd).PositionalAnyCompletion(carapace.ActionFiles(""))
}
7 changes: 7 additions & 0 deletions completers/gofmt_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/gofmt_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit a6a85b3

Please sign in to comment.