package sturgeon
Source file sturgeon_recipes_command.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25open Sturgeon let command ?greetings ?cogreetings () = let stdin = Sexp.of_channel stdin in let stdout sexp = Sexp.tell_sexp print_string sexp; print_newline (); flush stdout in let stdin', status = Session.connect ?greetings ?cogreetings stdout in let rec aux () = match stdin () with | None -> exit 0 | Some sexp -> stdin' sexp; if Session.pending_continuations status > 0 then aux () else exit 0 in aux () let text_command f = let open Sexp in let greetings, shell = Stui.buffer_greetings () in command ~greetings ~cogreetings:(fun args -> f ~args shell) ()