Skip to content

Commit

Permalink
general: added version subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Menet committed Dec 13, 2019
1 parent ef57e30 commit 50dfbeb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
)

var (
version string
commit string
date string

rootConfigPath string
rootQuiet bool
rootSingularityPath string
Expand Down Expand Up @@ -45,6 +49,8 @@ func init() {
rootCmd.AddCommand(deduceSingularityCmd)

rootCmd.AddCommand(listSingularityKeysCmd)

rootCmd.AddCommand(versionCmd)
}

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -155,6 +161,23 @@ var deduceSingularityCmd = &cobra.Command{
},
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print version info",
Run: func(cmd *cobra.Command, args []string) {
if version == "" {
version = "dirty"
}
if commit == "" {
commit = "dirty"
}
if date == "" {
date = "unknown"
}
fmt.Printf("Version: %s\nCommit: %s\nBuild Date: %s\n", version, commit, date)
},
}

func main() {
err := rootCmd.Execute()
exitOnErr(err)
Expand Down

0 comments on commit 50dfbeb

Please sign in to comment.