Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CmdVersion = "1.0.1"
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Short: "Update CLI if an update is available", Run: func(cmd *cobra.Command, args []string) { latestVersion, isLatestVersion := CmdIsLatestVersion() if isLatestVersion { color.Green("Haze is already running at the latest version") os.Exit(0) } path, _ := os.Executable() out, err := os.Create(path) if err != nil { color.Red("Error creating file at %v: %v", path, err.Error()) os.Exit(1) } assetFilename := fmt.Sprintf("haze-%v-%v", runtime.GOOS, runtime.GOARCH) downloadUrl := fmt.Sprintf("https://github.com/hunoz/haze/releases/download/%v/%v", latestVersion, assetFilename) response, err := http.Get(downloadUrl) if err != nil { color.Red("Error downloading latest version: %v", err.Error()) os.Exit(1) } defer response.Body.Close() _, err = io.Copy(out, response.Body) if err != nil { color.Red("Error updating to latest version: %v", err.Error()) } color.Green("Successfully updated Haze to version %v", latestVersion) }, }
Functions ¶
func CmdIsLatestVersion ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.