A simple interface to running child processes in Ponylang:
use "procs"
actor Main
new create(env: Env) =>
try
let result_promise = Procs.run_env(env, ["/usr/bin/echo"; "how"; "awesome"; "is"; "this;"])?
result_promise.next[None]({(res) =>
match res
| let pres: ProcessResult =>
env.out.write(pres.stdout)
| let perr: ProcessError =>
env.err.print("Meh! :(")
end
})
end
No need to create a ProcessNotify or a ProcessMonitor and
accumulate chunks received from stdout, while all you want is to get stdout as String
. Just run your process and
handle the Promise containing either the ProcessResult with exit_code
,
stdout
and stderr
or an instance of ProcessError.
It is possible to pass environment variables and write something to stdin of the child process.
- Install pony-stable
- Update your
bundle.json
{
"type": "github",
"repo": "mfelsche/pony-procs"
}
stable fetch
to fetch your dependenciesuse "procs"
to include this packagestable env ponyc
to compile your application