package dune-release

  1. Overview
  2. Docs

Safe OS operations.

All the commands in that module can have side-effects. They also all take a --dry-run parameter which cause the side-effect to be discarded and to display a message instead. Some of these commands also have a `--force` option: this causes the message to be printed AND the side-effects to be caused.

type error = Bos_setup.R.msg
val show : ?sandbox:bool -> ?action:[ `Done | `Skip ] -> ('a, Stdlib.Format.formatter, unit, (unit, 'b) Stdlib.result) Stdlib.format4 -> 'a
val cmd_error : Bos.Cmd.t -> string option -> Bos.OS.Cmd.status -> ('a, Rresult.R.msg) Stdlib.result

cmd_error cmd ~stderr status returns an error message describing the failing command cmd, the exit status status and, if existent, also the error message err_msg.

val run : dry_run:bool -> ?force:bool -> ?sandbox:bool -> Bos.Cmd.t -> (unit, error) Stdlib.result
val run_quiet : dry_run:bool -> ?force:bool -> ?sandbox:bool -> Bos.Cmd.t -> (unit, error) Stdlib.result

Same as run but redirects err and out to null

val run_io : dry_run:bool -> ?force:bool -> ?sandbox:bool -> default:'a -> Bos.Cmd.t -> Bos.OS.Cmd.run_in -> (Bos.OS.Cmd.run_out -> ('a, 'b) Stdlib.result) -> ('a, 'b) Stdlib.result
val run_out : dry_run:bool -> ?force:bool -> ?sandbox:bool -> ?err:Bos.OS.Cmd.run_err -> default:'a -> Bos.Cmd.t -> (Bos.OS.Cmd.run_out -> ('a, 'b) Stdlib.result) -> ('a, 'b) Stdlib.result
type 'a response = {
  1. output : 'a;
  2. err_msg : string;
  3. status : Bos.OS.Cmd.status;
  4. run_info : Bos.OS.Cmd.run_info;
}
val run_out_err : dry_run:bool -> ?force:bool -> ?sandbox:bool -> default:('a * Bos.OS.Cmd.run_status) -> Bos.Cmd.t -> (Bos.OS.Cmd.run_out -> ('a * Bos.OS.Cmd.run_status, [> Rresult.R.msg ] as 'b) Stdlib.result) -> ('a response, 'b) Stdlib.result
val run_status : dry_run:bool -> ?force:bool -> ?sandbox:bool -> Bos.Cmd.t -> (Bos.OS.Cmd.status, error) Stdlib.result
val delete_dir : dry_run:bool -> ?force:bool -> Fpath.t -> (unit, error) Stdlib.result
val delete_path : dry_run:bool -> Fpath.t -> (unit, error) Stdlib.result
val read_file : dry_run:bool -> Fpath.t -> (string, error) Stdlib.result
val write_file : dry_run:bool -> ?force:bool -> Fpath.t -> string -> (unit, error) Stdlib.result
val with_dir : dry_run:bool -> Fpath.t -> ('a -> 'b) -> 'a -> ('b, error) Stdlib.result
val file_exists : dry_run:bool -> Fpath.t -> (bool, error) Stdlib.result
val dir_exists : dry_run:bool -> Fpath.t -> (bool, error) Stdlib.result
val file_must_exist : dry_run:bool -> Fpath.t -> (Fpath.t, error) Stdlib.result
val out : 'a -> 'a * Bos.OS.Cmd.run_status
val mkdir : dry_run:bool -> Fpath.t -> (bool, error) Stdlib.result
val cp : dry_run:bool -> rec_:bool -> force:bool -> src:Fpath.t -> dst:Fpath.t -> (unit, error) Stdlib.result

cp ~dry_run ~rec ~force ~src ~dst copies src to dst. If rec is true, copies directories recursively. If force is true, overwrite existing files. The usual force arguments from other functions in this module is renamed force_side_effects here.

val relativize : src:Fpath.t -> dst:Fpath.t -> (Fpath.t, error) Stdlib.result

relativize ~src ~dst return a relative path from src to dst. If such a path can't be expressed, i.e. srs and dst don't have a common root, returns an error.

OCaml

Innovation. Community. Security.