Source

ocaml-shell-dsl / shell_dsl.mli

type env_var_name = string;

type var 'a;

type t 'a;
value s : string -> t string;
value v : var 'a -> t 'a;

type tlist 'a = t (list (t 'a));

value of_list : list (t string) -> tlist string;
value append : tlist string -> tlist string -> tlist string;

value is_file : t string -> t bool;
value is_exec : t string -> t bool;

value getenv : ?default:string -> env_var_name -> t string;

(* every [t] is evaluated to [res]
   (future, maybe:
      which will be passed to the enclosing [catch] block
   )
*)

type res = [= `Ok | `Error ];

value nop : t res;

(* [seq a b] = "do a, and, if success, then do b" *)
value seq : t res -> t res -> t res;

value print : tlist string -> t res;
value with_env_set : env_var_name -> t string -> t res -> t res;
value with_env_prepend : env_var_name -> t string -> t res -> t res;
value with_chdir : t string -> t res -> t res;
value if_ : t bool -> t 'a -> t 'a -> t 'a;
value let_ : t 'a -> (var 'a -> t 'b) -> t 'b;

(* fails when command exits with <>0 *)
value cmd : tlist string -> t res;

value script : t res -> string;