diff --git a/docs/user_docs/getting-started/install.md b/docs/user_docs/getting-started/install.md index bf45c757a..2cd180fc0 100644 --- a/docs/user_docs/getting-started/install.md +++ b/docs/user_docs/getting-started/install.md @@ -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 @@ -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. @@ -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 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/getting-started/install.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/getting-started/install.md index fffe76b2c..c542b5567 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/getting-started/install.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/user_docs/getting-started/install.md @@ -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 @@ -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) diff --git a/static/script/uninstall-cli.ps1 b/static/script/uninstall-cli.ps1 new file mode 100644 index 000000000..54f697157 --- /dev/null +++ b/static/script/uninstall-cli.ps1 @@ -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."