Skip to content

Commit

Permalink
Slight code qual improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
camerondurham committed Nov 20, 2021
1 parent 35c2211 commit 4820f96
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"github.com/camerondurham/ch/cmd/util"
"github.com/spf13/cobra"
"runtime"
)
Expand All @@ -14,7 +15,8 @@ var upgradeCmd = &cobra.Command{
Run: UpgradeCmd,
}

const GithubRepo = "https://github.com/camerondurham/ch"
const UnixUpgradeTerminalCommand = "bash <(curl -s https://github.com/camerondurham/ch/main/scripts/install-ch.sh)"
const WindowsUpgradeTerminalCommand = "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://github.com/camerondurham/ch/main/scripts/install-ch.ps1'))"

func UpgradeCmd(cmd *cobra.Command, args []string) {

Expand All @@ -28,17 +30,17 @@ func UpgradeCmd(cmd *cobra.Command, args []string) {
case "linux":
// set upgrade command
os = "Linux"
upgradeCommand = "bash <(curl -s https://github.com/camerondurham/ch/main/scripts/install-ch.sh)"
upgradeCommand = UnixUpgradeTerminalCommand
case "windows":
// set upgrade command
os = "Windows"
upgradeCommand = "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://github.com/camerondurham/ch/main/scripts/install-ch.ps1'))"
upgradeCommand = WindowsUpgradeTerminalCommand
}

fmt.Printf("You appear to be running a %s operating system."+
"\nPlease run the following upgrade command:"+
"\n\n %s"+
"\n\nFor more help, see the repository README: %s\n", os, upgradeCommand, GithubRepo)
"\n\nFor more help, see the repository README: %s\n", os, upgradeCommand, util.RepositoryUrl)

}

Expand Down

0 comments on commit 4820f96

Please sign in to comment.