1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-12 04:43:59 +00:00

refactor: standardize CLI with 'mo' alias and lowercase flags

Addresses tw93's PR #305 feedback:
- Add 'mo' short alias (mo.cmd) alongside mole.cmd
- Use 'mo' in all help text and documentation
- Document lowercase flag style (--dry-run, --help, etc.)
- Simplify optimize: repairs run automatically, no extra flags
- Fix RepairsApplied counter bug in optimize.ps1
- Update README with standardized examples
This commit is contained in:
Bhadra
2026-01-16 12:45:07 +05:30
parent 381a5f064c
commit 8e661a7b22
9 changed files with 148 additions and 162 deletions

View File

@@ -5,6 +5,8 @@
param(
[Parameter(Position = 0)]
[string]$Path,
[Alias('h')]
[switch]$ShowHelp
)
@@ -19,13 +21,13 @@ $binPath = Join-Path $windowsDir "bin\analyze.exe"
function Show-AnalyzeHelp {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1;35mMole Analyze$esc[0m - Interactive disk space analyzer"
Write-Host "$esc[1;35mmo analyze$esc[0m - Interactive disk space analyzer"
Write-Host ""
Write-Host "$esc[33mUsage:$esc[0m mole analyze [path]"
Write-Host "$esc[33mUsage:$esc[0m mo analyze [path]"
Write-Host ""
Write-Host "$esc[33mOptions:$esc[0m"
Write-Host " [path] Path to analyze (default: user profile)"
Write-Host " -ShowHelp Show this help message"
Write-Host " [path] Path to analyze (default: user profile)"
Write-Host " --help Show this help message"
Write-Host ""
Write-Host "$esc[33mKeybindings:$esc[0m"
Write-Host " Up/Down Navigate entries"

View File

@@ -4,11 +4,22 @@
#Requires -Version 5.1
[CmdletBinding()]
param(
[Alias('dry-run')]
[switch]$DryRun,
[Alias('s')]
[switch]$System,
[Alias('game-media')]
[switch]$GameMedia,
[Alias('d')]
[switch]$DebugMode,
[Alias('w')]
[switch]$Whitelist,
[Alias('h')]
[switch]$ShowHelp
)
@@ -45,23 +56,23 @@ $script:ExportListFile = "$env:USERPROFILE\.config\mole\clean-list.txt"
function Show-CleanHelp {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1;35mMole Clean$esc[0m - Deep cleanup for Windows"
Write-Host "$esc[1;35mmo clean$esc[0m - Deep cleanup for Windows"
Write-Host ""
Write-Host "$esc[33mUsage:$esc[0m mole clean [options]"
Write-Host "$esc[33mUsage:$esc[0m mo clean [options]"
Write-Host ""
Write-Host "$esc[33mOptions:$esc[0m"
Write-Host " -DryRun Preview changes without deleting (recommended first run)"
Write-Host " -System Include system-level cleanup (requires admin)"
Write-Host " -GameMedia Clean old game replays, screenshots, recordings (>90d)"
Write-Host " -Whitelist Manage protected paths"
Write-Host " -DebugMode Enable debug logging"
Write-Host " -ShowHelp Show this help message"
Write-Host " --dry-run Preview changes without deleting (recommended first run)"
Write-Host " --system Include system-level cleanup (requires admin)"
Write-Host " --game-media Clean old game replays, screenshots, recordings (>90d)"
Write-Host " --whitelist Manage protected paths"
Write-Host " --debug Enable debug logging"
Write-Host " --help Show this help message"
Write-Host ""
Write-Host "$esc[33mExamples:$esc[0m"
Write-Host " mole clean -DryRun # Preview what would be cleaned"
Write-Host " mole clean # Run standard cleanup"
Write-Host " mole clean -GameMedia # Include old game media cleanup"
Write-Host " mole clean -System # Include system cleanup (as admin)"
Write-Host " mo clean --dry-run # Preview what would be cleaned"
Write-Host " mo clean # Run standard cleanup"
Write-Host " mo clean --game-media # Include old game media cleanup"
Write-Host " mo clean --system # Include system cleanup (as admin)"
Write-Host ""
}
@@ -134,7 +145,7 @@ function Show-CleanupSummary {
Write-Host " Categories: $($Stats.TotalItems)"
Write-Host ""
Write-Host " Detailed list: $esc[90m$($script:ExportListFile)$esc[0m"
Write-Host " Run without -DryRun to apply cleanup"
Write-Host " Run without --dry-run to apply cleanup"
}
else {
Write-Host " Space freed: $esc[32m${sizeGB}GB$esc[0m"
@@ -192,14 +203,14 @@ function Start-Cleanup {
#
# How to protect files:
# 1. Copy any path below to $($script:Config.WhitelistFile)
# 2. Run: mole clean -Whitelist
# 2. Run: mo clean --whitelist
#
"@
Set-Content -Path $script:ExportListFile -Value $header
}
else {
Write-Host "$esc[90m$($script:Icons.Solid) Use -DryRun to preview, -Whitelist to manage protected paths$esc[0m"
Write-Host "$esc[90m$($script:Icons.Solid) Use --dry-run to preview, --whitelist to manage protected paths$esc[0m"
Write-Host ""
}

View File

@@ -4,15 +4,14 @@
#Requires -Version 5.1
[CmdletBinding()]
param(
[Alias('dry-run')]
[switch]$DryRun,
[Alias('d')]
[switch]$DebugMode,
[switch]$ShowHelp,
# Repair options
[switch]$Repair,
[switch]$Font,
[switch]$Icon,
[switch]$Search,
[switch]$Store
[Alias('h')]
[switch]$ShowHelp
)
Set-StrictMode -Version Latest
@@ -33,7 +32,6 @@ $libDir = Join-Path (Split-Path -Parent $scriptDir) "lib"
# ============================================================================
$script:OptimizationsApplied = 0
$script:RepairsApplied = 0
$script:IssuesFound = 0
$script:IssuesFixed = 0
@@ -44,37 +42,31 @@ $script:IssuesFixed = 0
function Show-OptimizeHelp {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1;35mMole Optimize$esc[0m - System optimization, health checks, and repairs"
Write-Host "$esc[1;35mmo optimize$esc[0m - System optimization and maintenance"
Write-Host ""
Write-Host "$esc[33mUsage:$esc[0m mole optimize [options]"
Write-Host "$esc[33mUsage:$esc[0m mo optimize [options]"
Write-Host ""
Write-Host "$esc[33mOptions:$esc[0m"
Write-Host " -DryRun Preview changes without applying"
Write-Host " -DebugMode Enable debug logging"
Write-Host " -ShowHelp Show this help message"
Write-Host " --dry-run Preview changes without applying"
Write-Host " --debug Enable debug logging"
Write-Host " --help Show this help message"
Write-Host ""
Write-Host "$esc[33mRepair Options:$esc[0m"
Write-Host " -Repair Run all repairs (Font, Icon, Search, Store)"
Write-Host " -Font Rebuild font cache (fixes font display issues)"
Write-Host " -Icon Rebuild icon cache (fixes missing/corrupt icons)"
Write-Host " -Search Reset Windows Search index (fixes search issues)"
Write-Host " -Store Reset Windows Store cache (fixes Store issues)"
Write-Host ""
Write-Host "$esc[33mExamples:$esc[0m"
Write-Host " mole optimize # Run standard optimizations"
Write-Host " mole optimize -Repair # Run optimizations + all repairs"
Write-Host " mole optimize -Icon -Font # Run optimizations + specific repairs"
Write-Host " mole optimize -DryRun # Preview what would happen"
Write-Host ""
Write-Host "$esc[33mOptimizations (always run):$esc[0m"
Write-Host " - Disk defragmentation/TRIM (SSD optimization)"
Write-Host " - Windows Search index check"
Write-Host "$esc[33mWhat it does:$esc[0m"
Write-Host " - Disk optimization (TRIM for SSD, defrag for HDD)"
Write-Host " - DNS cache flush"
Write-Host " - Network optimization"
Write-Host " - Network stack optimization"
Write-Host " - Font cache rebuild"
Write-Host " - Icon cache rebuild"
Write-Host " - Windows Search optimization"
Write-Host " - Windows Store cache reset"
Write-Host " - Startup program analysis"
Write-Host " - Disk health check"
Write-Host " - Windows Update status"
Write-Host ""
Write-Host "$esc[33mExamples:$esc[0m"
Write-Host " mo optimize # Run all optimizations"
Write-Host " mo optimize --dry-run # Preview what would happen"
Write-Host ""
}
# ============================================================================
@@ -495,7 +487,7 @@ function Repair-FontCache {
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Font Cache Service"
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete font cache files"
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Font Cache Service"
$script:RepairsApplied++
$script:OptimizationsApplied++
return
}
@@ -528,7 +520,7 @@ function Repair-FontCache {
Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Font cache rebuilt successfully"
Write-Host " $esc[90mNote: Some apps may need restart to see changes$esc[0m"
$script:RepairsApplied++
$script:OptimizationsApplied++
}
catch {
Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild font cache: $_"
@@ -556,7 +548,7 @@ function Repair-IconCache {
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Explorer"
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete icon cache files (iconcache_*.db)"
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Explorer"
$script:RepairsApplied++
$script:OptimizationsApplied++
return
}
@@ -591,7 +583,7 @@ function Repair-IconCache {
Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Icon cache rebuilt ($deletedCount files cleared)"
Write-Host " $esc[90mNote: Icons will rebuild gradually as you browse$esc[0m"
$script:RepairsApplied++
$script:OptimizationsApplied++
}
catch {
Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not rebuild icon cache: $_"
@@ -624,7 +616,7 @@ function Repair-SearchIndex {
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would stop Windows Search service"
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would delete search index database"
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would restart Windows Search service"
$script:RepairsApplied++
$script:OptimizationsApplied++
return
}
@@ -643,7 +635,7 @@ function Repair-SearchIndex {
Write-Host " $esc[32m$($script:Icons.Success)$esc[0m Search index reset successfully"
Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m Indexing will rebuild in the background (may take hours)"
$script:RepairsApplied++
$script:OptimizationsApplied++
}
catch {
Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset search index: $_"
@@ -667,7 +659,7 @@ function Repair-StoreCache {
if ($script:DryRun) {
Write-Host " $esc[33m$($script:Icons.DryRun)$esc[0m Would run wsreset.exe"
$script:RepairsApplied++
$script:OptimizationsApplied++
return
}
@@ -682,7 +674,7 @@ function Repair-StoreCache {
else {
Write-Host " $esc[33m$($script:Icons.Warning)$esc[0m wsreset completed with code $($wsreset.ExitCode)"
}
$script:RepairsApplied++
$script:OptimizationsApplied++
}
catch {
Write-Host " $esc[31m$($script:Icons.Error)$esc[0m Could not reset Store cache: $_"
@@ -708,20 +700,12 @@ function Show-OptimizeSummary {
Write-Host ""
if ($script:DryRun) {
$total = $script:OptimizationsApplied + $script:RepairsApplied
Write-Host " Would apply $esc[33m$total$esc[0m changes"
if ($script:RepairsApplied -gt 0) {
Write-Host " ($($script:OptimizationsApplied) optimizations, $($script:RepairsApplied) repairs)"
}
Write-Host " Run without -DryRun to apply changes"
Write-Host " Would apply $esc[33m$($script:OptimizationsApplied)$esc[0m optimizations"
Write-Host " Run without --dry-run to apply changes"
}
else {
Write-Host " Optimizations applied: $esc[32m$($script:OptimizationsApplied)$esc[0m"
if ($script:RepairsApplied -gt 0) {
Write-Host " Repairs applied: $esc[32m$($script:RepairsApplied)$esc[0m"
}
if ($script:IssuesFixed -gt 0) {
Write-Host " Issues fixed: $esc[32m$($script:IssuesFixed)$esc[0m"
}
@@ -757,15 +741,12 @@ function Main {
# Set dry-run mode
$script:DryRun = $DryRun
# Check if any repairs were requested
$runRepairs = $Repair -or $Font -or $Icon -or $Search -or $Store
# Clear screen
Clear-Host
$esc = [char]27
Write-Host ""
Write-Host "$esc[1;35mOptimize and Check$esc[0m"
Write-Host "$esc[1;35mOptimize and Maintain$esc[0m"
Write-Host ""
if ($script:DryRun) {
@@ -779,46 +760,20 @@ function Main {
# Run optimizations
Optimize-DiskDrive
Optimize-SearchIndex
Clear-DnsCache
Optimize-Network
# Run cache rebuilds (repairs integrated into optimize)
Repair-FontCache
Repair-IconCache
Optimize-SearchIndex
Repair-StoreCache
# Run health checks
Get-StartupPrograms
Test-DiskHealth
Test-WindowsUpdate
# Run repairs if requested
if ($runRepairs) {
Write-Host ""
Write-Host "$esc[1;35m$($script:Icons.Arrow) Repairs$esc[0m"
if ($Repair -or $Font) {
Repair-FontCache
}
if ($Repair -or $Icon) {
Repair-IconCache
}
if ($Repair -or $Search) {
Repair-SearchIndex
}
if ($Repair -or $Store) {
Repair-StoreCache
}
}
# System file check is slow, ask first (only if not doing repairs)
if (-not $runRepairs -and -not $script:DryRun -and (Test-IsAdmin)) {
Write-Host ""
$runSfc = Read-Host "Run System File Checker? This may take several minutes (y/N)"
if ($runSfc -eq 'y' -or $runSfc -eq 'Y') {
Test-SystemFiles
}
}
# Summary
Show-OptimizeSummary
}

View File

@@ -4,8 +4,13 @@
#Requires -Version 5.1
[CmdletBinding()]
param(
[Alias('d')]
[switch]$DebugMode,
[Alias('p')]
[switch]$Paths,
[Alias('h')]
[switch]$ShowHelp
)
@@ -74,14 +79,14 @@ $script:ItemsCleaned = 0
function Show-PurgeHelp {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1;35mMole Purge$esc[0m - Clean project build artifacts"
Write-Host "$esc[1;35mmo purge$esc[0m - Clean project build artifacts"
Write-Host ""
Write-Host "$esc[33mUsage:$esc[0m mole purge [options]"
Write-Host "$esc[33mUsage:$esc[0m mo purge [options]"
Write-Host ""
Write-Host "$esc[33mOptions:$esc[0m"
Write-Host " -Paths Edit custom scan directories"
Write-Host " -DebugMode Enable debug logging"
Write-Host " -ShowHelp Show this help message"
Write-Host " --paths Edit custom scan directories"
Write-Host " --debug Enable debug logging"
Write-Host " --help Show this help message"
Write-Host ""
Write-Host "$esc[33mDefault Search Paths:$esc[0m"
foreach ($path in $script:DefaultSearchPaths) {
@@ -550,7 +555,7 @@ function Main {
if ($null -eq $searchPaths -or $searchPaths.Count -eq 0) {
Write-MoleWarning "No valid search paths found"
Write-Host "Run 'mole purge -Paths' to configure search directories"
Write-Host "Run 'mo purge --paths' to configure search directories"
return
}

View File

@@ -3,6 +3,7 @@
#Requires -Version 5.1
param(
[Alias('h')]
[switch]$ShowHelp
)
@@ -17,12 +18,12 @@ $binPath = Join-Path $windowsDir "bin\status.exe"
function Show-StatusHelp {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1;35mMole Status$esc[0m - Real-time system health monitor"
Write-Host "$esc[1;35mmo status$esc[0m - Real-time system health monitor"
Write-Host ""
Write-Host "$esc[33mUsage:$esc[0m mole status"
Write-Host "$esc[33mUsage:$esc[0m mo status"
Write-Host ""
Write-Host "$esc[33mOptions:$esc[0m"
Write-Host " -ShowHelp Show this help message"
Write-Host " --help Show this help message"
Write-Host ""
Write-Host "$esc[33mDisplays:$esc[0m"
Write-Host " - System health score (0-100)"

View File

@@ -4,8 +4,13 @@
#Requires -Version 5.1
[CmdletBinding()]
param(
[Alias('d')]
[switch]$DebugMode,
[Alias('r')]
[switch]$Rescan,
[Alias('h')]
[switch]$ShowHelp
)
@@ -37,14 +42,14 @@ $script:CacheTTLHours = 24
function Show-UninstallHelp {
$esc = [char]27
Write-Host ""
Write-Host "$esc[1;35mMole Uninstall$esc[0m - Interactive application uninstaller"
Write-Host "$esc[1;35mmo uninstall$esc[0m - Interactive application uninstaller"
Write-Host ""
Write-Host "$esc[33mUsage:$esc[0m mole uninstall [options]"
Write-Host "$esc[33mUsage:$esc[0m mo uninstall [options]"
Write-Host ""
Write-Host "$esc[33mOptions:$esc[0m"
Write-Host " -Rescan Force rescan of installed applications"
Write-Host " -DebugMode Enable debug logging"
Write-Host " -ShowHelp Show this help message"
Write-Host " --rescan Force rescan of installed applications"
Write-Host " --debug Enable debug logging"
Write-Host " --help Show this help message"
Write-Host ""
Write-Host "$esc[33mFeatures:$esc[0m"
Write-Host " - Scans installed programs from registry and Windows Apps"