package opam-format

  1. Overview
  2. Docs
val items : (OpamTypes.opamfile_item list, (string * OpamTypes.value) list) OpamPp.t
val anonymous_section : ('a, 'b) OpamPp.t -> ((string option * 'a) list, 'b) OpamPp.t

Suitable for the fields sections argument, when the sections are anonymous (section_name = None)

type ('a, 'value) fields_def = (string * ('a, 'value) OpamPp.field_parser) list
val fields : ?name:string -> empty:'a -> ?sections: ('a, (string option * OpamTypes.opamfile_item list) list) fields_def -> ?mandatory_fields:string list -> ('a, OpamTypes.value) fields_def -> (OpamTypes.opamfile_item list, 'a * (string * OpamPp.bad_format) list) OpamPp.t

Parses an item list into a record using a fields_def; errors in a field cause the field to be ignored, and are aggregated into the returned field, bad_format list. Errors are ignored when printing back.

val show_errors : ?name:string -> ?strict:bool -> ?condition:('a -> bool) -> unit -> ('a * (string * OpamPp.bad_format) list, 'a) OpamPp.t

Intended to be piped after fields. If the errors list is non-empty, this raises Bad_format_list if strict, and otherwise prints warnings for all the errors. The errors are then dropped when parsing, and initialised to empty when printing. strict is taken from the global settings if unspecified. condition may be added to only show the errors when it returns true, and only log them otherwise.

val on_errors : ?name:string -> ('a -> (string * OpamPp.bad_format) -> 'a) -> ('a * (string * OpamPp.bad_format) list, 'a) OpamPp.t

Intended to be piped after fields, this processes the given function on the errors, then drops them when parsing. When printing, just sets empty errors.

val partition_fields : (string -> bool) -> (OpamTypes.opamfile_item list, OpamTypes.opamfile_item list * OpamTypes.opamfile_item list) OpamPp.t

Partitions items in an opamfile base on a condition on the variable names

Partitions items in an opamfile base on a generic condition on the items

val field : string -> (pos:OpamTypes.pos -> OpamTypes.value -> 'a) -> (OpamTypes.opamfile_item list, 'a option * OpamTypes.opamfile_item list) OpamPp.t

Parse a single field from a file, return the result and the unchanged item list. The single field is ignored when printing back.

val section : string -> (OpamTypes.opamfile_item, string option * OpamTypes.opamfile_item list) OpamPp.t

Parse a single section with the given "kind", towards its name and contents

val extract_field : string -> (OpamTypes.opamfile_item list, OpamTypes.value option * OpamTypes.opamfile_item list) OpamPp.t

Extracts a single item with the given variable name from an item list. The item is removed from the returned item list, and the two are re-combined when printing

val check_opam_version : ?optional:bool -> ?f:(OpamTypes.opam_version -> bool) -> unit -> (OpamTypes.opamfile_item list, OpamTypes.opamfile_item list) OpamPp.t

Checks the opam_version field; otherwise the identity

Signature handling (wip)

type signature = string * string * string

A signature is a keyid, an algorithm and the signature proper

exception Invalid_signature of OpamTypes.pos * (string * string * string) list option
val signed : check:(signature list -> string -> bool) -> (OpamTypes.opamfile_item list, signature list * OpamTypes.opamfile_item list) OpamPp.t

Pp for signed files. Will assert fail if attempting to write a file with an invalid signature.

OCaml

Innovation. Community. Security.