From b6fdf021b9f627843fe7ce270ec6c3219d13438d Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Tue, 17 Feb 2026 21:38:28 +0000 Subject: [PATCH] run formatter on examples --- examples/cli.ps1 | 14 +++++------ examples/commands.ps1 | 6 ++--- examples/gui.ps1 | 58 +++++++++++++++++++++---------------------- examples/messages.ps1 | 10 ++++---- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/examples/cli.ps1 b/examples/cli.ps1 index 118b5cb..77f4d2a 100644 --- a/examples/cli.ps1 +++ b/examples/cli.ps1 @@ -3,20 +3,20 @@ param() Import-Module ../lib/Q3Rcon.psm1 -Function Read-HostUntilEmpty { +function Read-HostUntilEmpty { param([object]$rcon) "Input 'Q' or to exit." - while (($line = Read-Host -Prompt "Send command") -cne [string]::Empty) { - if ($line -eq "Q") { + while (($line = Read-Host -Prompt 'Send command') -cne [string]::Empty) { + if ($line -eq 'Q') { break } - if ($line -in @("fast_restart", "map_rotate", "map_restart")) { + if ($line -in @('fast_restart', 'map_rotate', 'map_restart')) { $cmd = $line -replace '(?:^|_)(\p{L})', { $_.Groups[1].Value.ToUpper() } $rcon.$cmd() } - elseif ($line.StartsWith("map mp_")) { + elseif ($line.StartsWith('map mp_')) { $mapname = $line.Split()[1] $rcon.SetMap($mapname) } @@ -26,8 +26,8 @@ Function Read-HostUntilEmpty { } } -Function Get-ConnFromPSD1 { - $configpath = Join-Path $PSScriptRoot "config.psd1" +function Get-ConnFromPSD1 { + $configpath = Join-Path $PSScriptRoot 'config.psd1' return Import-PowerShellDataFile -Path $configpath } diff --git a/examples/commands.ps1 b/examples/commands.ps1 index ed0d338..dece09f 100644 --- a/examples/commands.ps1 +++ b/examples/commands.ps1 @@ -3,8 +3,8 @@ param() Import-Module ../lib/Q3Rcon.psm1 -Function Get-ConnFromPSD1 { - $configpath = Join-Path $PSScriptRoot "config.psd1" +function Get-ConnFromPSD1 { + $configpath = Join-Path $PSScriptRoot 'config.psd1' return Import-PowerShellDataFile -Path $configpath } @@ -14,7 +14,7 @@ try { $rcon.Map() - "Rotating the map..." + 'Rotating the map...' $rcon.MapRotate() Start-Sleep -Seconds 3 # wait for map to rotate diff --git a/examples/gui.ps1 b/examples/gui.ps1 index 87ed5fb..a6cb5c8 100644 --- a/examples/gui.ps1 +++ b/examples/gui.ps1 @@ -3,8 +3,8 @@ param() Import-Module ../lib/Q3Rcon.psm1 -[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") -[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") +[void] [System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') +[void] [System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') $OKB = New-Object System.Windows.Forms.Button $OTB = New-Object System.Windows.Forms.TextBox @@ -12,40 +12,40 @@ $CAB = New-Object System.Windows.Forms.Button $Lbl = New-Object System.Windows.Forms.Label $RLbl = New-Object System.Windows.Forms.Label -Function New-Form { +function New-Form { $form = New-Object System.Windows.Forms.Form - $form.Text = "Q3Rcon Client" + $form.Text = 'Q3Rcon Client' $form.Size = New-Object System.Drawing.Size(275, 200) - $form.StartPosition = "CenterScreen" + $form.StartPosition = 'CenterScreen' return $form } -Function Add-OkButton { +function Add-OkButton { param($form, $rcon) $OKB.Location = New-Object System.Drawing.Size(65, 100) $OKB.Size = New-Object System.Drawing.Size(65, 23) - $OKB.Text = "Send" + $OKB.Text = 'Send' $OKB.Add_Click({ Send-RconCommand -rcon $rcon }) $form.Controls.Add($OKB) } -Function Add-CloseButton($form) { +function Add-CloseButton($form) { $CAB.Location = New-Object System.Drawing.Size(140, 100) $CAB.Size = New-Object System.Drawing.Size(65, 23) - $CAB.Text = "Close" - $CAB.Add_Click({ Write-Host "Disconnecting from Rcon" -ForegroundColor Green; $form.Close() }) + $CAB.Text = 'Close' + $CAB.Add_Click({ Write-Host 'Disconnecting from Rcon' -ForegroundColor Green; $form.Close() }) $form.Controls.Add($CAB) } -Function Add-Label($form) { +function Add-Label($form) { $Lbl.Location = New-Object System.Drawing.Size(10, 20) $Lbl.Size = New-Object System.Drawing.Size(260, 20) - $Lbl.Text = "Input Rcon Command:" + $Lbl.Text = 'Input Rcon Command:' $form.Controls.Add($Lbl) } -Function Add-TextBox { +function Add-TextBox { param($form, $rcon) $OTB.Location = New-Object System.Drawing.Size(10, 50) @@ -58,31 +58,31 @@ Function Add-TextBox { $form.Controls.Add($OTB) } -Function Add-ResponseLabel($form) { +function Add-ResponseLabel($form) { $RLbl.Location = New-Object System.Drawing.Size(10, 75) $RLbl.Size = New-Object System.Drawing.Size(260, 20) - $RLbl.Text = "" + $RLbl.Text = '' $form.Controls.Add($RLbl) } -Function Start-Form($form) { +function Start-Form($form) { $form.Topmost = $true $form.Add_Shown({ $form.Activate() }) [void] $form.ShowDialog() } -Function Send-RconCommand() { +function Send-RconCommand() { param($rcon) $line = $OTB.Text $line | Write-Debug - if ($line -in @("fast_restart", "map_rotate", "map_restart")) { - $RLbl.Text = "" + if ($line -in @('fast_restart', 'map_rotate', 'map_restart')) { + $RLbl.Text = '' $cmd = $line -replace '(?:^|_)(\p{L})', { $_.Groups[1].Value.ToUpper() } $rcon.$cmd() } - elseif ($line.StartsWith("map mp_")) { - $RLbl.Text = "" + elseif ($line.StartsWith('map mp_')) { + $RLbl.Text = '' $mapname = $line.Split()[1] $rcon.SetMap($mapname) } @@ -91,19 +91,19 @@ Function Send-RconCommand() { } if ($resp -match '^["](?[a-z_]+)["]\sis[:]\s["](?.*?)\^7["]\s') { - $RLbl.Text = $Matches.name + ": " + $Matches.value + $RLbl.Text = $Matches.name + ': ' + $Matches.value } - $OTB.Text = "" + $OTB.Text = '' } -Function Get-ConnFromPSD1 { - $configpath = Join-Path $PSScriptRoot "config.psd1" +function Get-ConnFromPSD1 { + $configpath = Join-Path $PSScriptRoot 'config.psd1' return Import-PowerShellDataFile -Path $configpath } -Function Main { - BEGIN { +function Main { + begin { $conn = Get-ConnFromPSD1 $rcon = Connect-Rcon -hostname $conn.host -port $conn.port -passwd $conn.passwd Write-Host $rcon.base.ToString() -ForegroundColor Green @@ -115,10 +115,10 @@ Function Main { Add-ResponseLabel($form) Add-TextBox -form $form -rcon $rcon } - PROCESS { + process { Start-Form($form) } - END { + end { Disconnect-Rcon -rcon $rcon } } diff --git a/examples/messages.ps1 b/examples/messages.ps1 index 15ec526..72843bd 100644 --- a/examples/messages.ps1 +++ b/examples/messages.ps1 @@ -3,16 +3,16 @@ param() Import-Module ../lib/Q3Rcon.psm1 -Function Get-ConnFromPSD1 { - $configpath = Join-Path $PSScriptRoot "config.psd1" +function Get-ConnFromPSD1 { + $configpath = Join-Path $PSScriptRoot 'config.psd1' return Import-PowerShellDataFile -Path $configpath } -Function Get-DadJoke { - Invoke-WebRequest -Uri "https://icanhazdadjoke.com" -Headers @{accept = "application/json" } | Select-Object -ExpandProperty Content | ConvertFrom-Json | Select-Object -ExpandProperty Joke +function Get-DadJoke { + Invoke-WebRequest -Uri 'https://icanhazdadjoke.com' -Headers @{accept = 'application/json' } | Select-Object -ExpandProperty Content | ConvertFrom-Json | Select-Object -ExpandProperty Joke } -Function Send-Message { +function Send-Message { param($rcon) $msg = Get-DadJoke