module type COMMAND = sig
.. end
Provides an abstract type for easily building complex shell commands without making
quotation mistakes.
type
tags
type
pathname
type
t =
| |
Seq of t list |
| |
Cmd of spec |
| |
Echo of string list * pathname |
| |
Nop |
The type t
provides some basic combinators and command primitives.
Other commands can be made of command specifications (spec
).
type
spec =
The type for command specifications.
val atomize : string list -> spec
Will convert a string list to a list of atoms by adding A
constructors.
val atomize_paths : string list -> spec
Will convert a string list to a list of paths by adding P
constructors.
val execute : ?quiet:bool -> ?pretend:bool -> t -> unit
Run the command.
val execute_many : ?quiet:bool ->
?pretend:bool -> t list -> (bool list * exn) option
Run the commands in the given list, if possible in parallel.
See the module Ocamlbuild_executor
.
val setup_virtual_command_solver : string -> (unit -> spec) -> unit
setup_virtual_command_solver virtual_command solver
the given solver can raise Not_found if it fails to find a valid
command for this virtual command.
val search_in_path : string -> string
Search the given command in the command path and return its absolute
pathname.
val reduce : spec -> spec
Simplify a command by flattening the sequences and resolving the tags
into command-line options.
val print : Format.formatter -> t -> unit
Print a command (the format is not suitable to running the command).
val to_string : t -> string
Convert a command to a string (same format as print).
val string_of_command_spec : spec -> string
Build a string representation of a command that can be passed to the
system calls.