Up

module As_shell

: sig

Execution of shell commands.

Terminal Colors

#
type text_style = [
| `Bold
| `Underline
| `Black
| `Red
| `Green
| `Yellow
| `Blue
| `Magenta
| `Cyan
| `White
]
#
val color_default : [
| `Auto
| `Always
| `Never
] Pervasives.ref

color_default controls whether color will actually do coloring.

#
val color : text_style -> string -> string

color style s is s with style.

Output message to the terminal

#
val show : ('a, unit, string, unit) Pervasives.format4 -> 'a

show msg outputs the message msg on stdout.

#
val warn : ('a, unit, string, unit) Pervasives.format4 -> 'a

warn msg outputs the warning message msg on stderr.

#
val error : ('a, unit, string, unit) Pervasives.format4 -> 'a

error msg outputs the error message msg on stderr.

#
val fatal_error : int -> ('a, unit, string, 'b) Pervasives.format4 -> 'a

fatal_error i msg output the error message msg on stderr and stops the program with exit code i.

Execute commands

#
val verbose_default : bool Pervasives.ref

verbose_default defines the default value for the ?verbose argument of this module.

#
val has_cmd : string -> bool

has_cmd cmd is true iff the shell has the command cmd.

#
val exec : ?verbose:bool -> ('a, unit, string, unit) Pervasives.format4 -> 'a

Execute a shell command.

#
val exec_output : ?verbose:bool -> ('a, unit, string, string list) Pervasives.format4 -> 'a

Execute a shell command and returns its output.

#
val try_exec : ('a, unit, string, bool) Pervasives.format4 -> 'a

Try to run a given command.

#
val in_dir : string -> (unit -> 'a) -> 'a

Execute a command in a given directory.

end