Skip to content

Commit

Permalink
Merge pull request #1 from jjuarez/feature/add-version-command
Browse files Browse the repository at this point in the history
Feature/add version command
  • Loading branch information
jjuarez authored Jun 9, 2021
2 parents adb4642 + 83b2bc6 commit d57e18a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ builds:
- linux
- windows
- darwin
ldflags:
- -s -w -X github.com/jjuarez/iks-ctx-cleaner/cmd.Version={{ .Version }}
archives:
- replacements:
darwin: Darwin
Expand Down
7 changes: 7 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ func Execute() {
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVarP(&InputFile, "file", "f", "", "Input file to clean")

// Streams
rootCmd.SetOut(os.Stdout)
rootCmd.SetErr(os.Stderr)

// Adds the subcommands
rootCmd.AddCommand(versionCmd)
}

func initConfig() {
Expand Down
18 changes: 18 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

var Version = "v0.0.0+unknown"

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print ikscc version",
Long: "Print the version of the ikscc",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("ikscc version: %s", Version)
},
}

0 comments on commit d57e18a

Please sign in to comment.