Skip to content

Commit

Permalink
Merge pull request #268 from Peefy/add-uninstall-documents
Browse files Browse the repository at this point in the history
feat: add uninstall scripts and documents
  • Loading branch information
Peefy authored Feb 4, 2024
2 parents 9b6f28a + 9b77487 commit d21c5b4
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
18 changes: 18 additions & 0 deletions docs/user_docs/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Install or upgrade the latest darwin KCL to /usr/local/bin
curl -fsSL https://kcl-lang.io/script/install-cli.sh | /bin/bash
```

Uninstall

```bash
curl -fsSL https://kcl-lang.io/script/uninstall-cli.sh | /bin/bash
```

#### Linux

Install or upgrade the latest linux KCL to /usr/local/bin
Expand All @@ -42,6 +48,12 @@ Install or upgrade the latest linux KCL to /usr/local/bin
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
```

Uninstall

```bash
wget -q https://kcl-lang.io/script/uninstall-cli.sh -O - | /bin/bash
```

#### Windows

Install or upgrade the latest windows KCL to $Env:SystemDrive\kclvm\bin and add this directory to User PATH environment variable.
Expand All @@ -50,6 +62,12 @@ Install or upgrade the latest windows KCL to $Env:SystemDrive\kclvm\bin and add
powershell -Command "iwr -useb https://kcl-lang.io/script/install-cli.ps1 | iex"
```

Uninstall

```shell
powershell -Command "iwr -useb https://kcl-lang.io/script/uninstall-cli.ps1 | iex"
```

### Homebrew (MacOS)

- Install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ $env:PATH += ";{install-location};"
curl -fsSL https://kcl-lang.io/script/install-cli.sh | /bin/bash
```

卸载

```bash
curl -fsSL https://kcl-lang.io/script/uninstall-cli.sh | /bin/bash
```

#### Linux

将 KCL linux 最新版本安装到 /usr/local/bin
Expand All @@ -42,12 +48,24 @@ curl -fsSL https://kcl-lang.io/script/install-cli.sh | /bin/bash
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
```

卸载

```bash
wget -q https://kcl-lang.io/script/uninstall-cli.sh -O - | /bin/bash
```

#### Windows

将 KCL windows 最新版本安装到 $Env:SystemDrive\kclvm\bin,并将该目录添加到用户 PATH 环境变量中。

```bash
powershell -Command "iwr -useb https://kcl-lang.io/script/install-cli.ps1 | iex"
wget -q https://kcl-lang.io/script/uninstall-cli.sh -O - | /bin/bash
```

卸载

```shell
powershell -Command "iwr -useb https://kcl-lang.io/script/uninstall-cli.ps1 | iex"
```

#### Homebrew (MacOS)
Expand Down
45 changes: 45 additions & 0 deletions static/script/uninstall-cli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ------------------------------------------------------------
# Uninstallation script for KCL Binary
# ------------------------------------------------------------
param (
[string]$KCLRoot = "$Env:SystemDrive\kclvm"
)
Write-Output "Starting KCL uninstallation..."
$ErrorActionPreference = 'stop'

# Constants
$KCLCliFileName = "kcl.exe"
$KCLCliFileBinPath = "${KCLRoot}\bin"
$KCLCliFilePath = "${KCLCliFileBinPath}\${KCLCliFileName}"

# Remove KCL binary files
if (Test-Path $KCLCliFileBinPath) {
Write-Output "Removing KCL files from $KCLCliFileBinPath"
Remove-Item -Recurse -Force $KCLCliFileBinPath
} else {
Write-Output "KCL binary files not found. Skipping..."
}

# Remove KCL Root if it's empty
if (Test-Path $KCLRoot) {
if (!(Get-ChildItem -Path $KCLRoot -Recurse)) {
Write-Output "Removing empty KCL Root directory: $KCLRoot"
Remove-Item -Force $KCLRoot
} else {
Write-Output "KCL Root directory is not empty, skipping removal: $KCLRoot"
}
}

# Remove KCLRoot from User Path environment variable
Write-Output "Removing $KCLRoot from User Path Environment variable..."
$UserPathEnvironmentVar = Environment::GetEnvironmentVariable("PATH", "User")
if ($UserPathEnvironmentVar -like "*$KCLRoot*") {
$NewUserPath = ($UserPathEnvironmentVar -split ';' | Where-Object { $_ -ne $KCLRoot -and $_ -ne $KCLCliFileBinPath }) -join ';'
Environment::SetEnvironmentVariable("PATH", $NewUserPath, "User")
Write-Output "KCL directory removed from User Path."
} else {
Write-Output "KCL directory not found in User Path. Skipping..."
}

Write-Output "KCL has been uninstalled successfully."
Write-Output "Please restart your system or log off and on for the changes to take effect."

0 comments on commit d21c5b4

Please sign in to comment.