diff --git a/cmd/control/cmd/root.go b/cmd/control/cmd/root.go index 2116131..35c770d 100644 --- a/cmd/control/cmd/root.go +++ b/cmd/control/cmd/root.go @@ -58,6 +58,7 @@ func Execute(ver, com string) status.Code { rootCmd.AddCommand(statusCmd) + updateCmd.Flags().BoolVar(&betaFlag, "beta", false, "Update to latest version even if it's beta.") rootCmd.AddCommand(updateCmd) rootCmd.AddCommand(sanitizeCmd) diff --git a/cmd/control/cmd/update.go b/cmd/control/cmd/update.go index 4f7cc3f..dcdb21d 100644 --- a/cmd/control/cmd/update.go +++ b/cmd/control/cmd/update.go @@ -10,6 +10,7 @@ import ( "github.com/spf13/cobra" ) +var betaFlag bool var updateCmd = &cobra.Command{ Use: "update", Short: "check for updates and update RESH", @@ -17,7 +18,11 @@ var updateCmd = &cobra.Command{ usr, _ := user.Current() dir := usr.HomeDir rawinstallPath := filepath.Join(dir, ".resh/rawinstall.sh") - execCmd := exec.Command("bash", rawinstallPath) + execArgs := []string{rawinstallPath} + if betaFlag { + execArgs = append(execArgs, "--beta") + } + execCmd := exec.Command("bash", execArgs...) execCmd.Stdout = os.Stdout execCmd.Stderr = os.Stderr err := execCmd.Run() diff --git a/scripts/rawinstall.sh b/scripts/rawinstall.sh index c53dddf..ebc7c2a 100755 --- a/scripts/rawinstall.sh +++ b/scripts/rawinstall.sh @@ -6,8 +6,8 @@ echo echo "Please report any issues you encounter to: https://github.com/curusarn/resh/issues" echo -if [ "${1-}" = "--test" ] || [ "${1-}" = "-t" ]; then - echo "Looking for the latest release or PRERELEASE (because you used --test flag) ..." +if [ "${1-}" = "--beta" ] || [ "${1-}" = "-b" ]; then + echo "Looking for the latest release or PRERELEASE (because you used --beta flag) ..." # debug # latest release OR pre-release json=$(curl --silent "https://api.github.com/repos/curusarn/resh/releases")