diff --git a/examples/cli/CLI.ps1 b/examples/cli/CLI.ps1 index b319f71..c55bb49 100644 --- a/examples/cli/CLI.ps1 +++ b/examples/cli/CLI.ps1 @@ -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 to exit" | Write-Host - read-hostuntilflag -vmr $vmr + read-hostuntilempty -vmr $vmr return } $script | ForEach-Object { diff --git a/examples/cli/README.md b/examples/cli/README.md new file mode 100644 index 0000000..1b63f07 --- /dev/null +++ b/examples/cli/README.md @@ -0,0 +1,31 @@ +## About + +A simple voicemeeter-cli program. Offers ability to toggle, get and set parameters. + +## Use + +Toggle with `!` prefix, get by excluding `=` and set by including `=`. Mix and match arguments. + +You may pass the following optional flags: + +- -v: (-verbose) to toggle console output. +- -i: (-interactive) to toggle interactive mode. +- -k: (-kind) to set the kind of Voicemeeter. Defaults to banana. + +for example: + +`powershell.exe .\CLI.ps1 -o -k "banana" -s "strip[0].mute", "!strip[0].mute", "strip[0].mute", "bus[2].eq.on=1", "command.lock=1"` + +Expected output: + +``` +Getting strip[0].mute +strip[0].mute = 0 +Toggling strip[0].mute +Getting strip[0].mute +strip[0].mute = 1 +Setting bus[2].eq.on=1 +Setting command.lock=1 +``` + +If running in interactive mode enter `` to exit.