package bistro

  1. Overview
  2. Docs

Command-line construction

type template = Template_dsl.template
type command
include module type of Template_dsl with type template := template

Representation of scripts

val dest : template

Symbol representing the location where a workflow is expected to produce its result

val tmp : template

Symbol representing an existing empty directory that can be used as a temporary space for a workflow's execution.

val np : template

Symbol representing the number of cores allocated to the workflow

val mem : template

Symbol representing the memory size allocated to the workflow, in GB.

val string : string -> template

A chunk of text

val int : int -> template

Int formatting

val float : float -> template

Float formatting

val dep : _ path workflow -> template

dep w is interpreted as the path where to find the result of workflow w

val deps : ?quote:char -> sep:string -> _ path list workflow -> template
val string_dep : string workflow -> template

string_dep w is interpreted as the result of workflow w

val int_dep : int workflow -> template

int_dep w is interpreted as result of workflow w

val quote : ?using:char -> template -> template

quote ~using:c t surrounds template t with character c

val option : ('a -> template) -> 'a option -> template

option f o is f x if o = Some x and string "" otherwise

val list : ('a -> template) -> ?sep:string -> 'a list -> template

list combinator, optional value of sep is ","

val seq : ?sep:string -> template list -> template

another list combinator, default value for sep is ""

val enum : ('a * string) list -> 'a -> template

combinator for enumerations

val file_dump : template -> template

file_dump t can be used when a command needs a configuration script: at run-time, it will generate a text using t, save it to a path, deterministically chosen as a function of t. Finally the template file_dump t is interpreted as this path.

val cmd : string -> ?stdin:template -> ?stdout:template -> ?stderr:template -> template list -> command

Command-line constructor, e.g. cmd "echo" ~stdout:dest [ string "foo" ] will generate a shell command like "echo foo > /some/path".

  • parameter env

    specifies a Docker image where to run the command

  • parameter stdin

    adds a "< /some/path" token at the end of the command

  • parameter stdout

    adds a "> /some/path" token at the end of the command

  • parameter stderr

    adds a "2> /some/path" token at the end of the command

val bash : template -> command

Run a bash script, best used with %script {|...|}

val opt : string -> ('a -> template) -> 'a -> template

Command-line option formatting, e.g.: opt "--output" dep dest will be rendered like "--output /some/path"

val opt' : string -> ('a -> template) -> 'a -> template

Same as opt but renders options with an equal sign, e.g. "--output=/some/path"

val flag : ('a -> template) -> 'a -> bool -> template

flag f x b renders as f x if b is true

val or_list : command list -> command

OR-sequence of commands ( || )

val and_list : command list -> command

AND-sequence of commands ( && )

val pipe : command list -> command

Pipe of commands ( | )

val (//) : template -> string -> template

Similar to Filename.concat, but with other types.

Useful commands
val mkdir : template -> command
val mkdir_p : template -> command
val cd : template -> command
val rm_rf : template -> command
val mv : template -> template -> command
val docker_image : ?tag:string -> ?registry:string -> account:string -> name:string -> unit -> container_image

Construct a description of a publicly available docker image

val (%) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
OCaml

Innovation. Community. Security.