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 *)
31 (** Flags passed to the {!create} function. *)
34 | AugErrInternal (** Internal error (bug) *)
35 | AugErrPathX (** Invalid path expression *)
36 | AugErrNoMatch (** No match for path expression *)
37 | AugErrMMatch (** Too many matches for path expression *)
38 | AugErrSyntax (** Syntax error in lens file *)
39 | AugErrNoLens (** Lens lookup failed *)
40 | AugErrMXfm (** Multiple transforms *)
41 | AugErrNoSpan (** No span for this node *)
42 | AugErrMvDesc (** Cannot move node into its descendant *)
43 | AugErrCmdRun (** Failed to execute command *)
44 | AugErrBadArg (** Invalid argument in funcion call *)
45 | AugErrLabel (** Invalid label *)
46 | AugErrCpDesc (** Cannot copy node into its descendant *)
47 | AugErrUnknown of int
48 (** Possible error codes. *)
53 (** The operation mode for the {!transform} function. *)
55 exception Error of error_code * string * string * string
56 (** This exception is thrown when the underlying Augeas library
57 returns an error. The tuple represents:
58 - the Augeas error code
59 - the ocaml-augeas error string
60 - the human-readable explanation of the Augeas error, if available
61 - a string with details of the Augeas error
65 (** A path expression.
67 Note in future we may replace this with a type-safe path constructor. *)
72 val create : string -> string option -> flag list -> t
73 (** [create root loadpath flags] creates an Augeas handle.
75 [root] is a file system path describing the location
76 of the configuration files.
78 [loadpath] is an optional colon-separated list of directories
79 which are searched for schema definitions.
81 [flags] is a list of flags. *)
84 (** [close handle] closes the handle.
86 You don't need to close handles explicitly with this function:
87 they will be finalized eventually by the garbage collector.
88 However calling this function frees up any resources used by the
89 underlying Augeas library immediately.
91 Do not use the handle after closing it. *)
93 val get : t -> path -> value option
94 (** [get t path] returns the value at [path], or [None] if there
97 val exists : t -> path -> bool
98 (** [exists t path] returns true iff there is a value at [path]. *)
100 val insert : t -> ?before:bool -> path -> string -> unit
101 (** [insert t ?before path label] inserts [label] as a sibling
102 of [path]. By default it is inserted after [path], unless
103 [~before:true] is specified. *)
105 val rm : t -> path -> int
106 (** [rm t path] removes all nodes matching [path].
108 Returns the number of nodes removed (which may be 0). *)
110 val matches : t -> path -> path list
111 (** [matches t path] returns a list of path expressions
112 of all nodes matching [path]. *)
114 val count_matches : t -> path -> int
115 (** [count_matches t path] counts the number of nodes matching
116 [path] but does not return them (see {!matches}). *)
119 (** [save t] saves all pending changes to disk. *)
122 (** [load t] loads files into the tree. *)
124 val set : t -> path -> value option -> unit
125 (** [set t path] sets [value] as new value at [path]. *)
127 val transform : t -> string -> string -> transform_mode -> unit
128 (** [transform t lens file mode] adds or removes (depending on
129 [mode]) the transformation of the specified [lens] for [file]. *)