Created
November 12, 2012 11:02
-
-
Save raphink/4058691 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Module: Bacula | |
Parses: /etc/bacula/*.conf | |
Author: Domen Kožar <[email protected]> | |
About: Reference | |
This lens tries to be ... | |
About: License | |
This file is licenced under the LGPL v2+, like the rest of Augeas. | |
About: Lens Usage | |
See <lns>. | |
About: Configuration files | |
This lens applies to /etc/bacula/*.conf. | |
About: Examples | |
The <test_bacula.aug> file contains various examples and tests. | |
*) | |
module Bacula = | |
autoload xfm | |
let val = del /"?/ "\"" . store /[^# \t\n"]([^#\n"]*[^;# \t\n"])?/ . del /"?;?/ "\"" | |
let indent = Util.del_opt_ws "\t" | |
let equal = del /[ \t]*=[ \t]*/ " = " | |
(* TODO: support whitespace in key name *) | |
let line = indent . Build.key_value_line_comment Rx.word equal val Util.comment_eol | |
(* TODO: support file includes *) | |
let content = del /[ \t]*\{/ " {" . Util.comment_or_eol . line . del /[ \t]*\}/ "}" | |
(* TODO: support nested directives *) | |
let directive = [ key /[a-zA-Z]+/ . content ] | |
let lns = (directive|Util.empty|Util.comment)* | |
let filter = incl "/etc/bacula/*.conf" | |
. Util.stdexcl | |
let xfm = transform lns filter | |
test Bacula.line get "Name = kaki-sd\n" = { "Name" = "kaki-sd" } | |
test Bacula.lns get "Storage {\n Name = kaki-sd\n}" = | |
{"Storage" | |
{"Name" = "kaki-sd"} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment