mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 14:26:46 +00:00
fix(windows): fix encoding issues in PowerShell scripts
- Simplified banner in install.ps1 and ui.ps1 to avoid Unicode box-drawing characters that caused parsing errors on some Windows systems - Fixed PowerShell 5.1 compatibility for ANSI color codes using [char]27 - Renamed Show-Help to Show-InstallerHelp to avoid potential conflicts - Changed -Help parameter to -ShowHelp for consistency with mole.ps1
This commit is contained in:
@@ -9,7 +9,7 @@ param(
|
||||
[switch]$CreateShortcut,
|
||||
[switch]$Uninstall,
|
||||
[switch]$Force,
|
||||
[switch]$Help
|
||||
[switch]$ShowHelp
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -20,18 +20,23 @@ Set-StrictMode -Version Latest
|
||||
# ============================================================================
|
||||
|
||||
$script:VERSION = "1.0.0"
|
||||
$script:SourceDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$script:SourceDir = if ($MyInvocation.MyCommand.Path) {
|
||||
Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
} else {
|
||||
$PSScriptRoot
|
||||
}
|
||||
$script:ShortcutName = "Mole"
|
||||
|
||||
# Colors
|
||||
# Colors (using [char]27 for PowerShell 5.1 compatibility)
|
||||
$script:ESC = [char]27
|
||||
$script:Colors = @{
|
||||
Red = "`e[31m"
|
||||
Green = "`e[32m"
|
||||
Yellow = "`e[33m"
|
||||
Blue = "`e[34m"
|
||||
Cyan = "`e[36m"
|
||||
Gray = "`e[90m"
|
||||
NC = "`e[0m"
|
||||
Red = "$($script:ESC)[31m"
|
||||
Green = "$($script:ESC)[32m"
|
||||
Yellow = "$($script:ESC)[33m"
|
||||
Blue = "$($script:ESC)[34m"
|
||||
Cyan = "$($script:ESC)[36m"
|
||||
Gray = "$($script:ESC)[90m"
|
||||
NC = "$($script:ESC)[0m"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
@@ -65,14 +70,12 @@ function Write-Error {
|
||||
function Show-Banner {
|
||||
$c = $script:Colors
|
||||
Write-Host ""
|
||||
Write-Host " $($c.Cyan)╔╦╗╔═╗╦ ╔═╗$($c.NC)"
|
||||
Write-Host " $($c.Cyan)║║║║ ║║ ║╣ $($c.NC)"
|
||||
Write-Host " $($c.Cyan)╩ ╩╚═╝╩═╝╚═╝$($c.NC)"
|
||||
Write-Host " $($c.Cyan)MOLE$($c.NC)"
|
||||
Write-Host " $($c.Gray)Windows System Maintenance$($c.NC)"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
function Show-Help {
|
||||
function Show-InstallerHelp {
|
||||
Show-Banner
|
||||
|
||||
$c = $script:Colors
|
||||
@@ -93,7 +96,7 @@ function Show-Help {
|
||||
Write-Host ""
|
||||
Write-Host " $($c.Cyan)-Force$($c.NC) Overwrite existing installation"
|
||||
Write-Host ""
|
||||
Write-Host " $($c.Cyan)-Help$($c.NC) Show this help message"
|
||||
Write-Host " $($c.Cyan)-ShowHelp$($c.NC) Show this help message"
|
||||
Write-Host ""
|
||||
Write-Host " $($c.Green)EXAMPLES:$($c.NC)"
|
||||
Write-Host ""
|
||||
@@ -393,8 +396,8 @@ function Uninstall-Mole {
|
||||
# ============================================================================
|
||||
|
||||
function Main {
|
||||
if ($Help) {
|
||||
Show-Help
|
||||
if ($ShowHelp) {
|
||||
Show-InstallerHelp
|
||||
return
|
||||
}
|
||||
|
||||
@@ -414,7 +417,7 @@ try {
|
||||
}
|
||||
catch {
|
||||
Write-Host ""
|
||||
Write-Error "Installation failed: $_"
|
||||
Write-Host " $($script:Colors.Red)ERROR$($script:Colors.NC) Installation failed: $_"
|
||||
Write-Host ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -334,19 +334,10 @@ function Show-Banner {
|
||||
$cyan = $script:Colors.Cyan
|
||||
$nc = $script:Colors.NC
|
||||
|
||||
$banner = @"
|
||||
|
||||
${purple}███╗ ███╗ ██████╗ ██╗ ███████╗${nc}
|
||||
${purple}████╗ ████║██╔═══██╗██║ ██╔════╝${nc}
|
||||
${purple}██╔████╔██║██║ ██║██║ █████╗ ${nc}
|
||||
${purple}██║╚██╔╝██║██║ ██║██║ ██╔══╝ ${nc}
|
||||
${purple}██║ ╚═╝ ██║╚██████╔╝███████╗███████╗${nc}
|
||||
${purple}╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝${nc}
|
||||
${cyan}Windows System Maintenance${nc}
|
||||
|
||||
"@
|
||||
|
||||
Write-Host $banner
|
||||
Write-Host ""
|
||||
Write-Host " ${purple}MOLE${nc}"
|
||||
Write-Host " ${cyan}Windows System Maintenance${nc}"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
function Show-Header {
|
||||
|
||||
Reference in New Issue
Block a user