package opam-lib
Install
Dune Dependency
Authors
-
TThomas Gazagnaire <thomas@gazagnaire.org>
-
AAnil Madhavapeddy <anil@recoil.org>
-
FFabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
-
FFrederic Tuong <tuong@users.gforge.inria.fr>
-
LLouis Gesbert <louis.gesbert@ocamlpro.com>
-
GGuillem Rieu <guillem.rieu@ocamlpro.com>
-
VVincent Bernardoff <vb@luminar.eu.org>
-
RRoberto Di Cosmo <roberto@dicosmo.org>
Maintainers
Sources
sha256=625767c3465219cc8799aad1449c74279b31686db0821300cfdb92fbff17e9fd
md5=e0688c0cf9a55f93ee93f62d07cf6b74
doc/opam-lib.format/OpamFilter/index.html
Module OpamFilter
Manage filters
Filters are a small language of formulas over strings and booleans used for conditions and text replacements. It has relational operators over strings (using version-number comparison), And, Or and Not boolean operations, dynamic casting (using strings "true" and "false"), and string interpolation. Variables are resolved using a user function returning an option, undefined values are propagated.
String interpolation uses the syntax '%dentifier%'
Identifiers have the form
[package:]var[?str_if_true:str_if_false_or_undef]v}. The last optional part specifies a conversion from boolean to static strings. The syntax [pkg1+pkg2+pkgn:var] is allowed as a shortcut to [pkg1:var & pkg2:var & pkgn:var]. The special variable [pkg:enable] is allowed as a shortcut for [pkg:installed?enable:disable]
val to_string : OpamTypes.filter -> string
Pretty-print
val fold_down_left :
('a -> OpamTypes.filter -> 'a) ->
'a ->
OpamTypes.filter ->
'a
Folds on the tree of a filter
val variables : OpamTypes.filter -> OpamTypes.full_variable list
Returns all the variables appearing in a filter (including the ones within string interpolations
type env = OpamTypes.full_variable -> OpamTypes.variable_contents option
Type of filter environment.
type fident =
OpamTypes.name list * OpamTypes.variable * (string * string) option
The type of filter idents with (optionally multiple) qualifying package names and optional string converter
val expand_string : env -> string -> string
Rewrites string interpolations within a string
val eval :
?default:OpamTypes.variable_contents ->
env ->
OpamTypes.filter ->
OpamTypes.variable_contents
Computes the value of a filter. May raise Failure
if default
isn't provided
val eval_to_bool : ?default:bool -> env -> OpamTypes.filter -> bool
Like to_value
but casts the result to a bool. Raises Invalid_argument
if not a valid bool and no default supplied.
val opt_eval_to_bool : env -> OpamTypes.filter option -> bool
Same as eval_to_bool
, but takes an option as filter and returns always true
on None
, false
when the filter is Undefined
. This is the most common behaviour for using "filters" for filtering
val eval_to_string : ?default:string -> env -> OpamTypes.filter -> string
Like to_value
but casts the result to a string
val ident_of_var : OpamTypes.full_variable -> fident
Wraps a full_variable into a fident accessor
val ident_of_string : string -> fident
A fident accessor directly referring a variable with the given name
val ident_value :
?default:OpamTypes.variable_contents ->
env ->
fident ->
OpamTypes.variable_contents
Resolves a filter ident. Like eval
, may raise Failure if no default is provided
Like ident_value
, but casts the result to a string
Like ident_value
, but casts the result to a bool
val expand_interpolations_in_file : env -> OpamTypes.basename -> unit
Rewrites basename
.in to basename
, expanding interpolations
val commands : env -> OpamTypes.command list -> string list list
Processes filters evaluation in a command list: parameter expansion and conditional filtering
val single_command : env -> OpamTypes.arg list -> string list
Process a simpler command, without filters
val commands_variables : OpamTypes.command list -> OpamTypes.full_variable list
Extracts variables appearing in a list of commands