From 63a56c7a7246c4ca044306ac44c92f7a5eb1e4bd Mon Sep 17 00:00:00 2001 From: Onyx and Iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sun, 2 May 2021 13:34:13 +0100 Subject: [PATCH] add regex to base, remove tests from modules Parse multi set params using regex Remove tests from each module --- lib/base.ps1 | 23 +++++------------------ lib/bus.ps1 | 19 ------------------- lib/macrobuttons.ps1 | 14 -------------- lib/strip.ps1 | 20 -------------------- 4 files changed, 5 insertions(+), 71 deletions(-) diff --git a/lib/base.ps1 b/lib/base.ps1 index 1a2ac6e..44cccca 100644 --- a/lib/base.ps1 +++ b/lib/base.ps1 @@ -51,13 +51,10 @@ Function Param_Set_Multi { [string[]]$params = ($HASH | out-string -stream) -ne '' | Select-Object -Skip 2 [String]$cmd = [String]::new(512) ForEach ($line in $params) { - $line = $($line -replace '\s+', ' ') - $line = $line.TrimEnd() - $line = $line -replace '\s', '=' - $line = $line -replace 'True', '1' - $line = $line -replace 'False', '0' - - $cmd += $line + ';' + if($line.Trim() -Match "(^\w+)\[(\d)\].(\w+)\s+(\w+)") { + if($Matches[4] -eq "True") { $val = [String]1 } else { $val = [String]0 } + $cmd += "$($Matches[1])[$($Matches[2])].$($Matches[3])=$val;" + } } [String]$cmd = $cmd.SubString(1) @@ -212,7 +209,7 @@ Function Login { 'basic' { $vbtype = 1; Break} 'banana' { $vbtype = 2; Break} 'potato' { $vbtype = 3; Break} - Default { throw [LoginError]::new('Unknown Voicemeeter type') } + Default { throw [LoginError]::new('Unknown Voicemeeter type') } } $retval = [Int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([Int64]$vbtype) @@ -254,13 +251,3 @@ Function P_Dirty { Function M_Dirty { [Bool][Voicemeeter.Remote]::VBVMR_MacroButton_IsDirty() } - - -if ($MyInvocation.InvocationName -ne '.') -{ - Login - - Param_Set -PARAM 'garbagevalue' -Value $true - - Logout -} diff --git a/lib/bus.ps1 b/lib/bus.ps1 index 99461de..da56fd6 100644 --- a/lib/bus.ps1 +++ b/lib/bus.ps1 @@ -57,22 +57,3 @@ Function Buses { } $bus } - -if ($MyInvocation.InvocationName -ne '.') -{ - . .\voicemeeter.ps1 - try { - $vmr = [Remote]::new('potato') - - $vmr.bus[0].mono = $true - $vmr.bus[0].mono - $vmr.bus[0].mono = $false - $vmr.bus[0].mono - - $vmr.bus[1].gain = 3.2 - $vmr.bus[1].gain - $vmr.bus[2].gain = -2.0 - $vmr.bus[2].gain - } - finally { $vmr.Logout() } -} diff --git a/lib/macrobuttons.ps1 b/lib/macrobuttons.ps1 index ec41954..e5c7d98 100644 --- a/lib/macrobuttons.ps1 +++ b/lib/macrobuttons.ps1 @@ -59,17 +59,3 @@ Function Buttons { } $button } - -if ($MyInvocation.InvocationName -ne '.') -{ - . .\voicemeeter.ps1 - try { - $vmr = [Remote]::new('potato') - - $vmr.button[0].state = $true - $vmr.button[0].state - $vmr.button[0].state = $false - $vmr.button[0].state - } - finally { $vmr.Logout() } -} diff --git a/lib/strip.ps1 b/lib/strip.ps1 index 791d273..1151733 100644 --- a/lib/strip.ps1 +++ b/lib/strip.ps1 @@ -177,23 +177,3 @@ Function Strips { } $strip } - -if ($MyInvocation.InvocationName -ne '.') -{ - . .\voicemeeter.ps1 - try { - $vmr = [Remote]::new('potato') - - $vmr.strip[1].A1 = $true - $vmr.strip[1].A1 - $vmr.strip[2].A2 = $false - $vmr.strip[2].A2 - - - $vmr.strip[1].gain = 3.2 - $vmr.strip[1].gain - $vmr.strip[2].gain = -2.0 - $vmr.strip[2].gain - } - finally { $vmr.Logout() } -}