mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-04-18 13:33:31 +00:00
add output flag to CLI example
add README for CLI example
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
param(
|
||||
[switch]$interactive,
|
||||
[switch]$output,
|
||||
[Parameter(Mandatory)]
|
||||
[String]$kind,
|
||||
[String[]]$script = @()
|
||||
@@ -22,23 +23,24 @@ function msgHandler {
|
||||
param([object]$vmr, [string]$line)
|
||||
$line + " passed to handler" | Write-Debug
|
||||
if ($line[0] -eq "!") {
|
||||
if ($output) { "Toggling " + $line.substring(1) | Write-Host }
|
||||
$retval = get-value -vmr $vmr -line $line.substring(1)
|
||||
$vmr.Setter($line.substring(1), 1 - $retval)
|
||||
}
|
||||
elseif ($line.Contains("=")) {
|
||||
"Setting value $line" | Write-Debug
|
||||
if ($output) { "Setting $line" | Write-Host }
|
||||
$vmr.SendText($line)
|
||||
}
|
||||
else {
|
||||
"Getting value $line" | Write-Debug
|
||||
if ($output) { "Getting $line" | Write-Host }
|
||||
$retval = get-value -vmr $vmr -line $line
|
||||
$line + " = " + $retval | Write-Host
|
||||
}
|
||||
}
|
||||
|
||||
function read-hostuntilflag {
|
||||
function read-hostuntilempty {
|
||||
param([object]$vmr)
|
||||
while (($line = Read-Host) -cne [string]::Empty) { msgHandler -vmr $vmr -line $line }
|
||||
while (($line = Read-Host) -cne[string]::Empty) { msgHandler -vmr $vmr -line $line }
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +56,7 @@ function main {
|
||||
|
||||
if ($interactive) {
|
||||
"Press <Enter> to exit" | Write-Host
|
||||
read-hostuntilflag -vmr $vmr
|
||||
read-hostuntilempty -vmr $vmr
|
||||
return
|
||||
}
|
||||
$script | ForEach-Object {
|
||||
|
||||
Reference in New Issue
Block a user