From 70c327ff0303676631414238fd0f7c2244fc69b7 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 8 Nov 2024 23:23:38 +0100 Subject: [PATCH] [debug] now the PowerShell script works (thanks o1-preview and FUCK PowerShell) --- win-client.ps1 | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/win-client.ps1 b/win-client.ps1 index 3d90d45..1ce3c91 100644 --- a/win-client.ps1 +++ b/win-client.ps1 @@ -1,17 +1,24 @@ -# Set environment variable -$env:RUST_LOG = "info,lanspread_client=debug,lanspread_proto=debug" +$Env:RUST_LOG = "info,lanspread_client=debug,lanspread_proto=debug" -# Define a function to simulate the input sequence -function Simulate-Input { - while ($true) { - Start-Sleep -Milliseconds 100 - "list" - Start-Sleep -Milliseconds 100 - "get 1" - Start-Sleep -Milliseconds 100 - "get 25" - } +# Start the process with redirected standard input +$processInfo = New-Object System.Diagnostics.ProcessStartInfo +$processInfo.FileName = "cargo" +$processInfo.Arguments = "run -p lanspread-client -- $args" +$processInfo.UseShellExecute = $false +$processInfo.RedirectStandardInput = $true + +$process = New-Object System.Diagnostics.Process +$process.StartInfo = $processInfo +$process.Start() | Out-Null + +# Continuously write commands to the standard input of the process +while (!$process.HasExited) { + Start-Sleep -Milliseconds 100 + $process.StandardInput.WriteLine("list") + Start-Sleep -Milliseconds 100 + $process.StandardInput.WriteLine("get 1") + Start-Sleep -Milliseconds 100 + $process.StandardInput.WriteLine("get 25") } -# Run cargo command with piped input from the Simulate-Input function -Simulate-Input | cargo run -p lanspread-client -- $args +$process.WaitForExit()