package genspio

  1. Overview
  2. Docs

Compile EDSL.t values to much slower but more portable scripts (which use temporary-files).

Usage example:

let expression =
   Genspio.EDSL.(printf (str "Hello %s\\n") [get_stdout (exec ["whoami"])])
in
let (compiled : Genspio.Compile.To_slow_flow.Script.t) =
   Genspio.Compile.To_slow_flow.compile expression
in
let outchan = open_out "/tmp/my-script.sh" in
Format.fprintf
  (Format.formatter_of_out_channel outchan)
  "#!/bin/sh\n\n%a\n"
  Genspio.Compile.To_slow_flow.Script.pp_posix compiled;
close_out outchan
module Script : sig ... end

The result of compile function is a Script.t.

val compile : ?default_tmpdir:[ `Fresh | `Use of string ] -> ?signal_name:string -> ?trap:[ `Exit_with of int | `None ] -> 'a EDSL.t -> Script.t

Compile and EDSL.t value to a script.

  • ?default_tmpdir: set the value of the of the directory to create temporary files in, generated scripts still obey the "$TMPDIR" variable which takes precedence (default: `Fresh which means that it will create a fresh directory within "/tmp").
  • ?trap: whether to setup a call to "trap" to handle the calls to fail (default: `Exit_with 77)).
  • ?signal_name: if trap is not `None, this is the signal to use to self-kill the script on calling fail (default: "USR1").
OCaml

Innovation. Community. Security.