Skip to content

Commit

Permalink
feat: add version
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinthenight committed Jun 13, 2024
1 parent 7d9f492 commit bfae468
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmds/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmds

import (
"fmt"

"github.com/alphauslabs/bluectl/params"
"github.com/spf13/cobra"
)

func VersionCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Get current version",
Long: `Get current version.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("bluectl", params.Version)
},
}

cmd.Flags().SortFlags = false
return cmd
}
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
)

var (
version = "dev"
commit = "none"
date = "unknown"

bold = color.New(color.Bold).SprintFunc()
year = func() string {
return fmt.Sprintf("%v", time.Now().Year())
Expand All @@ -34,6 +38,7 @@ the ` + bold("--raw-input") + ` flag to be always in sync with the current featu
built-in flags don't support all the possible input combinations yet. For beta APIs, we recommend
you to use the ` + bold("--raw-input") + ` flag. See https://labs.alphaus.cloud/blueapidocs/ for the latest API reference.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
params.Version = version
if params.CleanOut {
logger.SetPrefix(logger.PrefixNone)
}
Expand Down Expand Up @@ -108,6 +113,7 @@ func init() {
cmds.BillingCmd(),
cmds.NotificationCmd(),
cmds.OpsCmd(),
cmds.VersionCmd(),
)
}

Expand Down
2 changes: 2 additions & 0 deletions params/params.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package params

var (
Version string

AuthProfile string
AuthUrl string
ClientId string
Expand Down

0 comments on commit bfae468

Please sign in to comment.