mirror of
https://github.com/tw93/Mole.git
synced 2026-02-14 22:15:09 +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]$CreateShortcut,
|
||||||
[switch]$Uninstall,
|
[switch]$Uninstall,
|
||||||
[switch]$Force,
|
[switch]$Force,
|
||||||
[switch]$Help
|
[switch]$ShowHelp
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
@@ -20,18 +20,23 @@ Set-StrictMode -Version Latest
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
$script:VERSION = "1.0.0"
|
$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"
|
$script:ShortcutName = "Mole"
|
||||||
|
|
||||||
# Colors
|
# Colors (using [char]27 for PowerShell 5.1 compatibility)
|
||||||
|
$script:ESC = [char]27
|
||||||
$script:Colors = @{
|
$script:Colors = @{
|
||||||
Red = "`e[31m"
|
Red = "$($script:ESC)[31m"
|
||||||
Green = "`e[32m"
|
Green = "$($script:ESC)[32m"
|
||||||
Yellow = "`e[33m"
|
Yellow = "$($script:ESC)[33m"
|
||||||
Blue = "`e[34m"
|
Blue = "$($script:ESC)[34m"
|
||||||
Cyan = "`e[36m"
|
Cyan = "$($script:ESC)[36m"
|
||||||
Gray = "`e[90m"
|
Gray = "$($script:ESC)[90m"
|
||||||
NC = "`e[0m"
|
NC = "$($script:ESC)[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -65,14 +70,12 @@ function Write-Error {
|
|||||||
function Show-Banner {
|
function Show-Banner {
|
||||||
$c = $script:Colors
|
$c = $script:Colors
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " $($c.Cyan)╔╦╗╔═╗╦ ╔═╗$($c.NC)"
|
Write-Host " $($c.Cyan)MOLE$($c.NC)"
|
||||||
Write-Host " $($c.Cyan)║║║║ ║║ ║╣ $($c.NC)"
|
|
||||||
Write-Host " $($c.Cyan)╩ ╩╚═╝╩═╝╚═╝$($c.NC)"
|
|
||||||
Write-Host " $($c.Gray)Windows System Maintenance$($c.NC)"
|
Write-Host " $($c.Gray)Windows System Maintenance$($c.NC)"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function Show-Help {
|
function Show-InstallerHelp {
|
||||||
Show-Banner
|
Show-Banner
|
||||||
|
|
||||||
$c = $script:Colors
|
$c = $script:Colors
|
||||||
@@ -93,7 +96,7 @@ function Show-Help {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " $($c.Cyan)-Force$($c.NC) Overwrite existing installation"
|
Write-Host " $($c.Cyan)-Force$($c.NC) Overwrite existing installation"
|
||||||
Write-Host ""
|
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 ""
|
||||||
Write-Host " $($c.Green)EXAMPLES:$($c.NC)"
|
Write-Host " $($c.Green)EXAMPLES:$($c.NC)"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
@@ -393,8 +396,8 @@ function Uninstall-Mole {
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
function Main {
|
function Main {
|
||||||
if ($Help) {
|
if ($ShowHelp) {
|
||||||
Show-Help
|
Show-InstallerHelp
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +417,7 @@ try {
|
|||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Error "Installation failed: $_"
|
Write-Host " $($script:Colors.Red)ERROR$($script:Colors.NC) Installation failed: $_"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,19 +334,10 @@ function Show-Banner {
|
|||||||
$cyan = $script:Colors.Cyan
|
$cyan = $script:Colors.Cyan
|
||||||
$nc = $script:Colors.NC
|
$nc = $script:Colors.NC
|
||||||
|
|
||||||
$banner = @"
|
Write-Host ""
|
||||||
|
Write-Host " ${purple}MOLE${nc}"
|
||||||
${purple}███╗ ███╗ ██████╗ ██╗ ███████╗${nc}
|
Write-Host " ${cyan}Windows System Maintenance${nc}"
|
||||||
${purple}████╗ ████║██╔═══██╗██║ ██╔════╝${nc}
|
Write-Host ""
|
||||||
${purple}██╔████╔██║██║ ██║██║ █████╗ ${nc}
|
|
||||||
${purple}██║╚██╔╝██║██║ ██║██║ ██╔══╝ ${nc}
|
|
||||||
${purple}██║ ╚═╝ ██║╚██████╔╝███████╗███████╗${nc}
|
|
||||||
${purple}╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝${nc}
|
|
||||||
${cyan}Windows System Maintenance${nc}
|
|
||||||
|
|
||||||
"@
|
|
||||||
|
|
||||||
Write-Host $banner
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Show-Header {
|
function Show-Header {
|
||||||
|
|||||||
Reference in New Issue
Block a user