feat(repl): Replace StdIO when executing IO-based monads #231

Merged
aniva merged 2 commits from repl/replace-io into dev 2025-07-08 14:30:51 -07:00
1 changed files with 4 additions and 1 deletions

View File

@ -267,7 +267,10 @@ def execute (command: Protocol.Command): MainM Json := do
try try
match fromJson? command.payload with match fromJson? command.payload with
| .ok args => do | .ok args => do
match (← comm args |>.run) with let (msg, result) ← IO.FS.withIsolatedStreams (isolateStderr := false) $ comm args
if !msg.isEmpty then
IO.eprint s!"stdout: {msg}"
match result with
| .ok result => return toJson result | .ok result => return toJson result
| .error ierror => return toJson ierror | .error ierror => return toJson ierror
| .error error => return toJson $ errorCommand s!"Unable to parse json: {error}" | .error error => return toJson $ errorCommand s!"Unable to parse json: {error}"