Skip to content

Commit

Permalink
add useragent (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamclaughlin authored Sep 1, 2021
1 parent b192e14 commit 2097373
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"golang.org/x/oauth2"
)

const (
userAgent = "vultr-cli/" + version
)

var cfgFile string
var client *govultr.Client

Expand Down Expand Up @@ -111,7 +115,7 @@ func initConfig() {
client = govultr.NewClient(oauth2.NewClient(context.Background(), ts))

client.SetRateLimit(1 * time.Second)

client.SetUserAgent(userAgent)
}

func getPaging(cmd *cobra.Command) *govultr.ListOptions {
Expand Down
10 changes: 7 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ import (
"github.com/spf13/cobra"
)

const (
version = "v2.8.0"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Display current version of Vultr-cli",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version())
fmt.Println(getVersion())
},
}

func version() string {
return "Vultr-cli v2.8.0"
func getVersion() string {
return fmt.Sprintf("Vultr-cli %s", version)
}

0 comments on commit 2097373

Please sign in to comment.