WinMole.psm1

#Requires -Version 7.0

<#
.SYNOPSIS
    Root module for WinMole
.DESCRIPTION
    PowerShell-powered Windows system cleaner and optimizer with Spectre Console UI.
#>


$script:ModuleRoot = $PSScriptRoot

# Dot-source library files
$libPath = Join-Path -Path $script:ModuleRoot -ChildPath 'lib'
if (Test-Path -Path $libPath) {
    $libFiles = Get-ChildItem -Path $libPath -Filter '*.ps1' -File
    foreach ($file in $libFiles) {
        try {
            . $file.FullName
            Write-Verbose "Imported lib: $($file.BaseName)"
        } catch {
            Write-Error "Failed to import lib $($file.FullName): $_"
        }
    }
}

# Register the 'mo' alias pointing to the main CLI entry point
$moScript = Join-Path -Path $script:ModuleRoot -ChildPath 'WinMole.ps1'
if (Test-Path -Path $moScript) {
    Set-Alias -Name 'mo' -Value $moScript -Scope Global
}