kareman / SwiftShell

A Swift framework for shell scripting.
https://kareman.github.io/SwiftShell
MIT License
1.03k stars 87 forks source link

Async Misunterstanding #29

Closed melMass closed 7 years ago

melMass commented 7 years ago

Hi Kameran,

I'm having hard time understanding your Async implementation. I'm not using SS in CLI but as part of a GUI app. I'm trying to bind the PID's output to the UI.

Before SwiftShell I used to chain a fileHandle to a Notification Center Observer in background which allowed me to update GUI or anything Async.

I'm trying to find the same paradigm in SS but all my attempts to get stdout block the program. Is SS meant for such task or am I stuck with the Process>Pipe>FileHandle(in BG)>NCObserver

kareman commented 7 years ago

Hi, have you tried using the onStringOutput method?

let cmd = runAsync("cmd")
cmd.stdout.onStringOutput { output:String in 
    // called every time there is new output
}
melMass commented 7 years ago

Thanks that's what I was looking for