Skip to content

Commit

Permalink
✨ Add --version flag to root command
Browse files Browse the repository at this point in the history
  • Loading branch information
5n7-sk committed Aug 2, 2020
1 parent b6224b4 commit f93459c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/gmoji/cmd/cmd_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ import (

// RootOptions represents the options for root command.
type RootOptions struct {
Hook string
Hook string
Version bool
}

var (
rootOptions RootOptions
)

func runRoot(cmd *cobra.Command, args []string) error {
if rootOptions.Version {
if err := runVersion(cmd, args); err != nil {
return err
}
return nil
}

c, err := cli.NewCLI()
if err != nil {
return err
Expand All @@ -41,4 +49,5 @@ func Execute() {

func init() {
rootCmd.Flags().StringVar(&rootOptions.Hook, "hook", "", "hook path (.git/COMMIT_EDITMSG)")
rootCmd.Flags().BoolVarP(&rootOptions.Version, "version", "V", false, "show version")
}

0 comments on commit f93459c

Please sign in to comment.