Skip to content

Commit

Permalink
Update package and commands with version info
Browse files Browse the repository at this point in the history
  • Loading branch information
emi80 committed Jan 27, 2023
1 parent 216a612 commit 2be399d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"

"github.com/guigolab/rnaget-client/pkg/api"
"github.com/guigolab/rnaget-client/pkg/version"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -37,6 +38,7 @@ var (
Use: "rnaget-client",
Short: "A demo client for the GA4GH RNAget API",
Long: `A demo client for the GA4GH RNAget API`,
Version: version.Get(),
PersistentPreRun: getConfig,
SilenceUsage: true,
SilenceErrors: true,
Expand Down
21 changes: 21 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package version

import (
"fmt"
"time"
)

var (
version = "dev"
date = ""
commit = ""
)

func Get() string {
parsedDate, err := time.Parse(time.RFC3339, date)
if err != nil {
panic(err)
}
formattedDate := parsedDate.Format(time.RFC1123)
return fmt.Sprintf("%s\n= Git commit: \t%s\n= Built: \t%s", version, commit, formattedDate)
}

0 comments on commit 2be399d

Please sign in to comment.