mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Added version command and corresponding implementation
This commit is contained in:
parent
6d61511e36
commit
c8297534cc
2 changed files with 66 additions and 0 deletions
24
cmd/version.go
Normal file
24
cmd/version.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
magellan "github.com/OpenCHAMI/magellan/internal"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if cmd.Flag("rev").Value.String() == "true" {
|
||||
fmt.Println(magellan.VersionCommit())
|
||||
} else {
|
||||
fmt.Println(magellan.VersionTag())
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
versionCmd.Flags().Bool("rev", false, "show the version commit")
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue