Skip to content

Commit

Permalink
Add --beta flag to reshctl update
Browse files Browse the repository at this point in the history
  • Loading branch information
curusarn committed Dec 11, 2021
1 parent a88aced commit c212a81
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/control/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion cmd/control/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ import (
"github.com/spf13/cobra"
)

var betaFlag bool
var updateCmd = &cobra.Command{
Use: "update",
Short: "check for updates and update RESH",
Run: func(cmd *cobra.Command, args []string) {
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()
Expand Down
4 changes: 2 additions & 2 deletions scripts/rawinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c212a81

Please sign in to comment.