Skip to content

Commit ff3f33b

Browse files
committed
add update command
1 parent bfda019 commit ff3f33b

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,9 @@ Run eslint --fix on running containers (Clark and SCE-discord-bot only):
9595
sce lint <project>
9696
```
9797
Make sure the project is running with `sce run` first.
98+
99+
### Update
100+
Update the SCE CLI to the latest version. Runs the appropriate install script for your platform:
101+
```
102+
sce update
103+
```

go/cmd/update.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package cmd
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
"runtime"
7+
8+
"github.com/spf13/cobra"
9+
)
10+
11+
const (
12+
unixInstallURL = "https://raw.githubusercontent.com/SCE-Development/SCE-CLI/master/go/install.sh"
13+
windowsInstallURL = "https://raw.githubusercontent.com/SCE-Development/SCE-CLI/master/go/install.ps1"
14+
)
15+
16+
var updateCmd = &cobra.Command{
17+
Use: "update",
18+
Short: "Update the SCE CLI to the latest version",
19+
Args: cobra.NoArgs,
20+
Run: func(cmd *cobra.Command, args []string) {
21+
var c *exec.Cmd
22+
if runtime.GOOS == "windows" {
23+
c = exec.Command("powershell", "-Command",
24+
"Invoke-WebRequest -Uri \""+windowsInstallURL+"\" -UseBasicParsing | Invoke-Expression")
25+
} else {
26+
c = exec.Command("sh", "-c", "curl -sSL "+unixInstallURL+" | sh")
27+
}
28+
c.Stdout = os.Stdout
29+
c.Stderr = os.Stderr
30+
c.Stdin = os.Stdin
31+
if err := c.Run(); err != nil {
32+
os.Exit(1)
33+
}
34+
},
35+
}
36+
37+
func init() {
38+
rootCmd.AddCommand(updateCmd)
39+
}

0 commit comments

Comments
 (0)