Skip to content

Commit

Permalink
add versioning (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
agrimrules authored Jun 30, 2021
1 parent 232a626 commit d8e6a7c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ builds:
- linux
- windows
- darwin
ldflags:
- -s -w -X github.com/agrimrules/hashmatch/cmd.version=v{{.Version}}
archives:
- replacements:
darwin: Darwin
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/spf13/cobra"
)

var version = "dev"

var rootCmd = &cobra.Command{
Use: "hashmatch",
Short: "print hashes of files in tabular form",
Expand Down
36 changes: 36 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright © 2021 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Current version",
Long: `Prints the version of the tool currently installed`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("version " + version)
},
}

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

0 comments on commit d8e6a7c

Please sign in to comment.