1 (** Augeas OCaml bindings *)
2 (* Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 * $Id: augeas.mli,v 1.2 2008/05/06 10:48:20 rjones Exp $
22 (** Augeas library handle. *)
25 | AugSaveBackup (** Rename original with .augsave *)
26 | AugSaveNewFile (** Save changes to .augnew *)
27 | AugTypeCheck (** Type-check lenses *)
34 | AugTraceModuleLoading
35 (** Flags passed to the {!create} function. *)
38 | AugErrInternal (** Internal error (bug) *)
39 | AugErrPathX (** Invalid path expression *)
40 | AugErrNoMatch (** No match for path expression *)
41 | AugErrMMatch (** Too many matches for path expression *)
42 | AugErrSyntax (** Syntax error in lens file *)
43 | AugErrNoLens (** Lens lookup failed *)
44 | AugErrMXfm (** Multiple transforms *)
45 | AugErrNoSpan (** No span for this node *)
46 | AugErrMvDesc (** Cannot move node into its descendant *)
47 | AugErrCmdRun (** Failed to execute command *)
48 | AugErrBadArg (** Invalid argument in funcion call *)
49 | AugErrLabel (** Invalid label *)
50 | AugErrCpDesc (** Cannot copy node into its descendant *)
51 | AugErrUnknown of int
52 (** Possible error codes. *)
57 (** The operation mode for the {!transform} function. *)
59 exception Error of error_code * string * string * string * string
60 (** This exception is thrown when the underlying Augeas library
61 returns an error. The tuple represents:
62 - the Augeas error code
63 - the ocaml-augeas error string
64 - the Augeas error message
65 - the human-readable explanation of the Augeas error, if available
66 - a string with details of the Augeas error
70 (** A path expression.
72 Note in future we may replace this with a type-safe path constructor. *)
77 val create : string -> string option -> flag list -> t
78 (** [create root loadpath flags] creates an Augeas handle.
80 [root] is a file system path describing the location
81 of the configuration files.
83 [loadpath] is an optional colon-separated list of directories
84 which are searched for schema definitions.
86 [flags] is a list of flags. *)
89 (** [close handle] closes the handle.
91 You don't need to close handles explicitly with this function:
92 they will be finalized eventually by the garbage collector.
93 However calling this function frees up any resources used by the
94 underlying Augeas library immediately.
96 Do not use the handle after closing it. *)
98 val defnode : t -> string -> string -> string option -> int * bool
99 (** [defnode t name expr value] defines [name] whose value is the
100 result of evaluating [expr], which is a nodeset. *)
102 val defvar : t -> string -> string option -> int option
103 (** [defvar t name expr] defines [name] whose value is the result
104 of evaluating [expr], replacing the old value if existing.
105 [None] as [expr] removes the variable [name]. *)
107 val get : t -> path -> value option
108 (** [get t path] returns the value at [path], or [None] if there
111 val exists : t -> path -> bool
112 (** [exists t path] returns true iff there is a value at [path]. *)
114 val insert : t -> ?before:bool -> path -> string -> unit
115 (** [insert t ?before path label] inserts [label] as a sibling
116 of [path]. By default it is inserted after [path], unless
117 [~before:true] is specified. *)
119 val label : t -> path -> string option
120 (** [label t path] gets the label of [path].
122 Returns [Some value] when [path] matches only one node, and
123 that has an associated label. *)
125 val rm : t -> path -> int
126 (** [rm t path] removes all nodes matching [path].
128 Returns the number of nodes removed (which may be 0). *)
130 val matches : t -> path -> path list
131 (** [matches t path] returns a list of path expressions
132 of all nodes matching [path]. *)
134 val mv : t -> path -> path -> unit
135 (** [mv t src dest] moves a node. *)
137 val count_matches : t -> path -> int
138 (** [count_matches t path] counts the number of nodes matching
139 [path] but does not return them (see {!matches}). *)
142 (** [save t] saves all pending changes to disk. *)
145 (** [load t] loads files into the tree. *)
147 val set : t -> path -> value option -> unit
148 (** [set t path] sets [value] as new value at [path]. *)
150 val setm : t -> path -> string option -> value option -> int
151 (** [setm t base sub value] sets [value] as new value for all the
152 nodes under [base] that match [sub] (or all, if [sub] is
155 Returns the number of nodes modified. *)
157 val transform : t -> string -> string -> transform_mode -> unit
158 (** [transform t lens file mode] adds or removes (depending on
159 [mode]) the transformation of the specified [lens] for [file]. *)
161 val source : t -> path -> path option
162 (** [source t path] returns the path to the node representing the
163 file to which [path] belongs, or [None] if [path] does not
164 represent any file. *)