Skip to content

Commit

Permalink
Create version.go
Browse files Browse the repository at this point in the history
  • Loading branch information
raullenchai authored Nov 10, 2023
1 parent 6e97dc9 commit 862dedc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cmd/wsctl/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// Version is set during build time using -ldflags
var Version string

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of wsctl",
Long: `All software has versions. This is wsctl's version.`,
Run: func(cmd *cobra.Command, args []string) {
if Version == "" {
Version = "development" // default version if not set during build
}
fmt.Printf("wsctl version: %s\n", Version)
},
}

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

0 comments on commit 862dedc

Please sign in to comment.