Skip to content

Instantly share code, notes, and snippets.

@raphink
Last active January 3, 2016 20:49
Show Gist options
  • Save raphink/8517851 to your computer and use it in GitHub Desktop.
Save raphink/8517851 to your computer and use it in GitHub Desktop.
$ augparse -I . cim.aug
Test result: cim.aug:17.0-24.4:
{ "#comment" = "comment" }
{ "credentials" = "username:password" }
{ "port" = "4673" }
{ "@define" = "property"
{ "value" = "value" }
}
{ "@define" = "cxws.log.File"
{ "value" = "cxws.log" }
}
{ "@define" = "cxws.log.MaxFileSize"
{ "value" = "30MB" }
}
{ "@define" = "cxws.log.MaxBackupIndex"
{ "value" = "3" }
}
$ augtool -I . -r . --noautoload --transform "Cim.lns incl /cim.conf" print /files
/files
/files/cim.conf
/files/cim.conf/#comment[1] = "###############################################"
/files/cim.conf/#comment[2] = "Optional parameters to start cim extension"
/files/cim.conf/#comment[3] = "To enable a switch, set the switch value and remove the '#' sign"
/files/cim.conf/#comment[4] = "Copy this file to cim.extension.parameters. Change the parameters as required."
/files/cim.conf/#comment[5] = "cim.extension.parameters file will be saved when the cim extension is upgraded."
/files/cim.conf/#comment[6] = "###############################################"
/files/cim.conf/#comment[7] = "Accept uname and pword as acceptable credentials."
/files/cim.conf/#comment[8] = "Use multiple entries for multiple credentials."
/files/cim.conf/credentials[1] = "<uname1>:<pword1>"
/files/cim.conf/credentials[2] = "<uname2>:<pword2>"
/files/cim.conf/credentials[3] = "username:password"
/files/cim.conf/#comment[9] = "Restrict CIM Extension to listen only to specific SE server ip address."
/files/cim.conf/#comment[10] = "Use comma separated values for multiple addresses."
/files/cim.conf/mgmtServerIP = "127.0.0.1,192.168.0.1"
/files/cim.conf/#comment[11] = "The CIM Extensions agent communication port. (default is 4673)"
/files/cim.conf/port = "4673"
/files/cim.conf/#comment[12] = "Set java system property. Multiple entries are allowed."
/files/cim.conf/@define[1] = "property"
/files/cim.conf/@define[1]/value = "value"
/files/cim.conf/#comment[13] = "Default settings for cxws.log"
/files/cim.conf/#comment[14] = "Note: In order to change the default settings for this log, uncomment the below lines"
/files/cim.conf/#comment[15] = "and set their values appropriately."
/files/cim.conf/@define[2] = "cxws.log.File"
/files/cim.conf/@define[2]/value = "cxws.log"
/files/cim.conf/@define[3] = "cxws.log.MaxFileSize"
/files/cim.conf/@define[3]/value = "30MB"
/files/cim.conf/@define[4] = "cxws.log.MaxBackupIndex"
/files/cim.conf/@define[4]/value = "3"
/files/cim.conf/#comment[16] = "Default settings for nb-parser.log"
/files/cim.conf/#comment[17] = "Note: In order to change the default settings for this log, uncomment the below lines"
/files/cim.conf/#comment[18] = "and set their values appropriately."
/files/cim.conf/@define[5] = "parser.log.File"
/files/cim.conf/@define[5]/value = "nb-parser.log"
/files/cim.conf/@define[6] = "parser.log.MaxFileSize"
/files/cim.conf/@define[6]/value = "10MB"
/files/cim.conf/@define[7] = "parser.log.MaxBackupIndex"
/files/cim.conf/@define[7]/value = "10"
module Cim =
let define_gen (kw:lens) (lns:lens) =
[ Util.indent . Util.del_str "-"
. kw . Sep.space . lns
. Util.eol ]
let define =
define_gen
(Util.del_str "D" . label "@define")
(store Rx.word . Sep.equal . [ label "value" . store Rx.word ])
let entry =
define_gen
(key (Rx.word - "D"))
(store /[^# \t\n].*[^ \t\n]|[^# \t\n]/)
let lns = (Util.empty | Util.comment | define | entry)*
test lns get "# comment
-credentials username:password
-port 4673
-D property=value
-D cxws.log.File=cxws.log
-D cxws.log.MaxFileSize=30MB
-D cxws.log.MaxBackupIndex=3
" = ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment