Skip to content

Commit

Permalink
Resolve issue #30 (#43)
Browse files Browse the repository at this point in the history
Co-authored-by: Evgenii Orlov <evgenii.orlov@semrush.com>
  • Loading branch information
OrlovEvgeny and Evgenii Orlov authored Jul 21, 2021
1 parent 0ebcff2 commit 9b9a66f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"spotify/internal/back"
"spotify/internal/device"
"spotify/internal/#"
Expand Down Expand Up @@ -33,7 +34,7 @@ func main() {
root := &cobra.Command{
Use: "spotify",
Short: "Spotify for the terminal 🎵",
Version: "1.9.2",
Version: buildVersion(version, commit, date),
PersistentPreRunE: promptUpdate,
}

Expand All @@ -59,6 +60,24 @@ func main() {
_ = root.Execute()
}

// Sets ldflags by goreleaser https://goreleaser.com/customization/build/ (default values)
var (
version = "dev"
commit string
date string
)

func buildVersion(version, commit, date string) string {
result := version
if commit != "" {
result = fmt.Sprintf("%s\ncommit: %s", result, commit)
}
if date != "" {
result = fmt.Sprintf("%s\nbuilt at: %s", result, date)
}
return result
}

func promptUpdate(cmd *cobra.Command, _ []string) error {
if time.Now().Unix() < viper.GetInt64("prompt_update_timer") {
return nil
Expand Down

0 comments on commit 9b9a66f

Please # to comment.