Skip to content

Commit

Permalink
Merge pull request #144 from rsteube/add-gofmt
Browse files Browse the repository at this point in the history
added gofmt
  • Loading branch information
rsteube authored Sep 17, 2020
2 parents 7bc8055 + a6a85b3 commit 0021568
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 0021568

Please sign in to comment.