GinShell.psm1

# Test function
function Test-GinShell {
    Write-Host "GinShell module is working correctly!"
}

# Log writing function
function Write-Log {
    param(
        [Parameter(Mandatory = $true)]
        [string]$Message,
        [Parameter(Mandatory = $false)]
        [string]$LogFile = "$env:ProgramData\GinShell\logs\GinShell.log",
        [Parameter(Mandatory = $false)]
        [ValidateSet('Info','Warning','Error')]
        [string]$LogLevel = 'Info',
        [Parameter(Mandatory = $false)]
        [bool]$EnableFileLogging = $true
    )   
    $Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $LogMessage = "$Timestamp [$LogLevel] - $Message"
    
    # Write to console with appropriate color
    switch($LogLevel) {
        'Info' { Write-Host $LogMessage -ForegroundColor Green }
        'Warning' { Write-Host $LogMessage -ForegroundColor Yellow }
        'Error' { Write-Host $LogMessage -ForegroundColor Red }
    }
    
    # Write to log file if enabled
    if ($EnableFileLogging) {
        # Create logs directory if it doesn't exist
        $logDirectory = Split-Path $LogFile -Parent
        if (-not (Test-Path $logDirectory)) {
            New-Item -ItemType Directory -Path $logDirectory -Force | Out-Null
        }
        
        # Write to log file
        Add-Content -Path $LogFile -Value $LogMessage
    }
}



# Export members
Export-ModuleMember -Function Write-Log, Test-GinShell