Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / cockpit.aug
1 (*
2 Module: Cockpit
3  Cockpit module for Augeas
4
5  Author: Pat Riehecky <riehecky@fnal.gov>
6
7 About: Configuration files
8  cockpit.conf is a standard INI File.
9
10 About: License
11   This file is licenced under the LGPL v2+, like the rest of Augeas.
12 *)
13
14 module Cockpit =
15   autoload xfm
16
17 (************************************************************************
18  * INI File settings
19  *************************************************************************)
20
21 let comment  = IniFile.comment "#" "#"
22 let sep      = IniFile.sep "=" "="
23 let empty    = Util.empty
24 let eol      = IniFile.eol
25
26 (************************************************************************
27  *                        ENTRY
28  *************************************************************************)
29
30 let list_entry (list_key:string)  =
31   let list_value = store /[^# \t\r\n,][^ \t\r\n,]*[^# \t\r\n,]|[^# \t\r\n,]/ in
32   let list_sep = del /([ \t]*(,[ \t]*|\r?\n[ \t]+))|[ \t]+/ " " in
33   [ key list_key . sep . Sep.opt_space . list_value ]
34   . (list_sep . Build.opt_list [ label list_key . list_value ] list_sep)?
35   . eol
36
37 let entry_re = IniFile.entry_re - ("Origins" | "Fatal")
38
39 let entry       = IniFile.entry entry_re sep comment
40                 | empty
41
42 let entries =
43      let list_entry_elem (k:string) = list_entry k . entry*
44   in entry*
45    | entry* . Build.combine_two_opt
46                 (list_entry_elem "Origins")
47                 (list_entry_elem "Fatal")
48
49
50 (***********************************************************************a
51  *                         TITLE
52  *************************************************************************)
53 let title       = IniFile.title IniFile.record_re
54 let record      = [ title . entries ]
55
56
57 (************************************************************************
58  *                         LENS & FILTER
59  *************************************************************************)
60 let lns    = (empty | comment)* . record*
61
62 let filter = (incl "/etc/cockpit/cockpit.conf")
63
64 let xfm = transform lns filter