module Cmd:sig..end
Cmd provides functions to execute non-build commands
and perform IO operations. They can be used to define the default
value of configuration keys in assemble files.
type'aresult =[ `Error of string | `Ok of 'a ]
val ret : 'a -> 'a resultret v is `Ok v.val error : string -> 'a resulterror e is `Error e.val bind : 'a result ->
('a -> 'b result) -> 'b resultbind r f is f v if r = `Ok v and r if r = `Error _.val map : 'a result -> ('a -> 'b) -> 'b resultmap r f is bind r (fun v -> ret (f v)).val get : 'a result -> 'aget r is v if r = `Ok v andInvalid_argument otherwise.val on_error : ?level:Assemblage.Log.level -> use:'a -> 'a result -> 'aon_error ~level ~use r is:
v if r = `Ok vuse if r = `Error msg. As a side effect msg is
logged with level level (defaults to
Log.Error)val ignore_error : use:'a -> 'a result -> 'a
val reword_error : ?replace:bool ->
string -> 'a result -> 'a resultreword_error msg r uses msg for the error message in case of
`Error. If replace is false (default), msg is stacked on
top of the old message.val exn_error : ?msg:(Printexc.raw_backtrace -> exn -> 'a -> string) ->
('a -> 'b) -> 'a -> 'b result
val (>>=) : 'a result ->
('a -> 'b result) -> 'b resultr >>= f is bind r f.val (>>|) : 'a result -> ('a -> 'b) -> 'b resultr >>| f is map r f.module Infix:sig..end
typepath =Assemblage.Path.t
module Path:sig..end
module File:sig..end
module Dir:sig..end
module Vcs:sig..end
val env : string -> string optionenv var is the value if the environment variable var, if
defined.val get_env : string -> string result
val exists : string -> bool resultexists cmd is true if cmd exists and can be invoked.val exec_ret : string -> string list -> intexec_ret cmd args executes cmd with arguments args and
returns the exit code of the invocation.val exec : string -> string list -> unit resultexec cmd args executes cmd with arguments args. On exit
code 0 returns `Ok (). Otherwise an error message with
the failed invocation and its exit code is returned in `Error.val read : ?trim:bool -> string -> string list -> string resultread cmd args execute cmd with arguments args and returns
its standard output. If cmd's return code is non zero returns
an error message. If trim is true (default) the contents is
passed to String.trim before being returned.val read_lines : string -> string list -> string list resultinput_lines cmd args is like input ~trim:false cmd args but
the input is splitted at '\n'.val write : string -> string list -> path -> unit resultwrite cmd args file execute cmd with arguments args and writes
the invocation's stdout to file. In cmd's return code is non
zero returns an error message and file is left intact.