mirror of
https://github.com/chshersh/github-tui.git
synced 2024-09-11 10:35:35 +03:00
17 lines
478 B
OCaml
17 lines
478 B
OCaml
let collect_chan (channel : in_channel) : string =
|
|
let rec loop acc =
|
|
match input_line channel with
|
|
| exception End_of_file -> acc
|
|
| line -> loop (acc ^ line ^ "\n")
|
|
in
|
|
loop ""
|
|
|
|
let proc_stdout cmd =
|
|
let env = Unix.environment () in
|
|
let ((proc_stdout, _proc_stdin, _proc_stderr) as process) =
|
|
Unix.open_process_full cmd env
|
|
in
|
|
let stdout_result = collect_chan proc_stdout in
|
|
let _ = Unix.close_process_full process in
|
|
String.trim stdout_result
|