Skip to content

Commit

Permalink
Merge pull request #10 from Hashnode/scriptonist/version-command
Browse files Browse the repository at this point in the history
Add version command
  • Loading branch information
scriptonist authored Jan 16, 2019
2 parents dfd8b3c + c6276b3 commit e0c1d6a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ builds:
- windows
goarch:
- amd64
ldflags:
- -X "github.com/hashnode/hashnode-cli/cmd.version={{ .Version }}" -X "github.com/hashnode/hashnode-cli/cmd.commithash={{ .FullCommit }}"

archive:
name_template: "hashnode-{{ .Os }}-{{ .Arch }}"
format_overrides:
Expand Down
22 changes: 22 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

var version, commithash string

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print version number of hashnode",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Release: %s\nCommit: %s\n", version, commithash)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}

0 comments on commit e0c1d6a

Please sign in to comment.