Skip to content

Commit

Permalink
Update root command invocation style (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmiyake authored Apr 28, 2018
1 parent 926ff9d commit 2929f66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 9 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
package cmd

import (
"github.com/palantir/pkg/cobracli"
"github.com/spf13/cobra"

"github.com/palantir/go-license/commoncmd"
"github.com/palantir/go-license/golicense"
)

var (
RootCmd = &cobra.Command{
rootCmd = &cobra.Command{
Use: "go-license [flags] [files]",
Short: "Write or verify license headers for Go files",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -33,8 +34,12 @@ var (
removeFlagVal bool
)

func Execute() int {
return cobracli.ExecuteWithDefaultParams(rootCmd)
}

func init() {
RootCmd.Flags().StringVar(&cfgFlagVal, "config", "", "the YAML configuration file for the license check")
RootCmd.Flags().BoolVar(&verifyFlagVal, "verify", false, "verify that files have proper license headers applied")
RootCmd.Flags().BoolVar(&removeFlagVal, "remove", false, "remove the license header from files (no-op if verify is true)")
rootCmd.Flags().StringVar(&cfgFlagVal, "config", "", "the YAML configuration file for the license check")
rootCmd.Flags().BoolVar(&verifyFlagVal, "verify", false, "verify that files have proper license headers applied")
rootCmd.Flags().BoolVar(&removeFlagVal, "remove", false, "remove the license header from files (no-op if verify is true)")
}
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ package main
import (
"os"

"github.com/palantir/pkg/cobracli"

"github.com/palantir/go-license/cmd"
)

func main() {
os.Exit(cobracli.ExecuteWithDefaultParams(cmd.RootCmd))
os.Exit(cmd.Execute())
}

0 comments on commit 2929f66

Please sign in to comment.