CheatLab.psm1
|
$moduleRoot = $PSScriptRoot if (-not $moduleRoot) { $moduleRoot = Split-Path -Parent $MyInvocation.MyCommand.Path } $scriptFiles = @( "modules/CheatLab.Core.ps1", "modules/CheatLab.Commands.ps1" ) foreach ($scriptFile in $scriptFiles) { $scriptPath = Join-Path $moduleRoot $scriptFile if (-not (Test-Path $scriptPath)) { throw "Missing CheatLab module file: $scriptPath" } . $scriptPath } function cheat { param( [Parameter(Position = 0, Mandatory = $false)] [ValidateSet("get", "post", "delete", "ai", "config", "upload", "download")] [string]$method, [Parameter(Position = 1, Mandatory = $false)] [string]$endpoint, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$additionalFiles, [Alias("t")] [string]$text, [Alias("p")] [string]$password, [Alias("ap")] [string]$admin_pass, [Alias("k")] [string]$key, [Alias("w")] [string]$who, [Alias("o")] [string]$outfile, [string]$username, [string]$auth_key, [Alias("pvi")] [switch]$protect_view, [Alias("pd")] [switch]$protect_delete, [Alias("c")] [switch]$confidential, [Alias("d")] [switch]$details, [ValidateRange(1, 30)] [int]$days = 3, [Alias("cb")] [switch]$clipboard, [switch]$help ) if ($confidential) { $protect_view = $true $protect_delete = $true } if ($help) { Show-CheatLabHelp return } switch ($method) { "config" { Invoke-CheatConfig -Username $username -AuthKey $auth_key return } "ai" { Invoke-CheatAi -BaseUrl $script:CheatLabBaseUrl -Endpoint $endpoint return } "get" { Invoke-CheatGet -BaseUrl $script:CheatLabBaseUrl -Endpoint $endpoint -Password $password -AdminPass $admin_pass -Details:$details return } "post" { Invoke-CheatPost -BaseUrl $script:CheatLabBaseUrl -Endpoint $endpoint -Text $text -Who $who -Password $password -Key $key -ProtectView:$protect_view -ProtectDelete:$protect_delete -Confidential:$confidential return } "delete" { Invoke-CheatDelete -BaseUrl $script:CheatLabBaseUrl -Endpoint $endpoint -Password $password -AdminPass $admin_pass return } "upload" { Invoke-CheatUpload -BaseUrl $script:CheatLabBaseUrl -Endpoint $endpoint -AdditionalFiles $additionalFiles -Key $key -Password $password -Who $who -Days $days -ProtectView:$protect_view -ProtectDelete:$protect_delete -Confidential:$confidential -Clipboard:$clipboard return } "download" { Invoke-CheatDownload -BaseUrl $script:CheatLabBaseUrl -Endpoint $endpoint -Password $password -AdminPass $admin_pass -Outfile $outfile -AdditionalFiles $additionalFiles return } default { if ($method) { Write-Host "Error: unknown method '$method'" -ForegroundColor Red } } } } Export-ModuleMember -Function cheat, file, htype, update-cheat |