Skip to content

Commit 52fd658

Browse files
committed
Rename variables, replace prompt with notify
1 parent e8026c9 commit 52fd658

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

internal/pkg/updatecheck/updatecheck.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/loophole/cli/internal/pkg/communication"
1212
"github.com/mitchellh/go-homedir"
1313
"github.com/ncruces/zenity"
14-
"github.com/pkg/browser"
1514
"github.com/spf13/viper"
1615
)
1716

@@ -42,34 +41,35 @@ func CheckVersion() {
4241
if !remind {
4342
return
4443
}
45-
dlLink := getDownloadLink(availableVersion.Version)
46-
response, _ := zenity.Question(fmt.Sprintf("A new version is available for you at \n%s \nDo you want to open the link in your browser now?", dlLink), zenity.NoWrap(), zenity.Title("New version available!"))
47-
if response {
48-
browser.OpenURL(dlLink)
44+
downloadlink := getDownloadLink(availableVersion.Version)
45+
err = zenity.Notify(fmt.Sprintf("A new version is available for you at \n%s \n", downloadlink), zenity.Title("New version available!"))
46+
if err != nil {
47+
communication.Debug(err.Error()) //errors in showing a download link should be noted, but not interrupt the program
4948
}
5049
}
5150
}
5251
}
5352

5453
func getDownloadLink(availableVersion string) string {
55-
archiveExt := ".tar.gz"
56-
arch := runtime.GOARCH
57-
if arch == "windows" {
58-
archiveExt = ".zip"
59-
} else if arch == "darwin" {
60-
arch = "macos"
54+
archiveType := ".tar.gz"
55+
operatingSystem := runtime.GOOS
56+
architecture := runtime.GOARCH
57+
if operatingSystem == "windows" {
58+
archiveType = ".zip"
59+
} else if operatingSystem == "darwin" {
60+
operatingSystem = "macos" //rename for use in downloadlink
6161
}
62-
if arch == "amd64" {
63-
arch = "64bit"
64-
} else if arch == "386" {
65-
arch = "32bit"
62+
if architecture == "amd64" {
63+
architecture = "64bit"
64+
} else if architecture == "386" {
65+
architecture = "32bit"
6666
} else {
6767
communication.Error("There was an error detecting your system architecture.") //if arch is unexpected, only link to the release page
6868
return fmt.Sprintf("https://github.com/loophole/cli/releases/tag/%s", availableVersion)
6969
}
70-
res := fmt.Sprintf("https://github.com/loophole/cli/releases/download/%s/loophole-desktop_%s_%s_%s%s", availableVersion, availableVersion, runtime.GOOS, arch, archiveExt)
71-
fmt.Println(res)
72-
return res
70+
link := fmt.Sprintf("https://github.com/loophole/cli/releases/download/%s/loophole-desktop_%s_%s_%s%s", availableVersion, availableVersion, operatingSystem, operatingSystem, archiveType)
71+
fmt.Println(link)
72+
return link
7373
}
7474

7575
func remindAgainCheck() (bool, error) {
@@ -81,7 +81,7 @@ func remindAgainCheck() (bool, error) {
8181
layout := "2006-02-01" //golangs arcane time format string
8282
viper.SetDefault("last-reminder", time.Time{}.Format(layout)) //zero value for time
8383
viper.SetConfigName("config") // name of config file (without extension)
84-
viper.SetConfigType("json") // REQUIRED if the config file does not have the extension in the name
84+
viper.SetConfigType("json")
8585
viper.AddConfigPath(fmt.Sprintf("%s/.loophole/", home))
8686
if err := viper.ReadInConfig(); err != nil {
8787
if _, ok := err.(viper.ConfigFileNotFoundError); ok { //create a config if none exist yet

0 commit comments

Comments
 (0)