[augeas-devel] Playing with comments

Raphaël Pinson raphink at gmail.com
Fri Jul 11 15:22:10 UTC 2008


Hi list,

I've been playing with comments a bit. Here is the code I've been playing
with. I hope it can be useful :

======================================
module CommentTest =

   autoload xfm

   let comment = [ label "commented" . del /#[ \t\n]*/ "# " ]

   let record = [ seq "record" . comment? . store /[^# \t\n][^#\n]*/ .
Util.del_str "\n" ]

   let lns = record*

   let conf ="test
#test2
"

   let filter = (incl "/commenttest")

   let xfm = transform lns filter

========================================


And then :

$ cat commenttest
# test
this is another test line
and a third
# fourth line
$ augtool -r . -I .
augtool> print /files/commenttest/
/files/commenttest
/files/commenttest/1 = "test"
/files/commenttest/1/commented
/files/commenttest/2 = "this is another test line"
/files/commenttest/3 = "and a third"
/files/commenttest/4 = "fourth line"
/files/commenttest/4/commented
augtool> rm /files/commenttest/4/commented
rm : /files/commenttest/4/commented 1
augtool> set /files/commenttest/3/commented " "
augtool> save
# test
this is another test line
# and a third
fourth line


The only down side of this is that set cannot place flags, but only set
values, when 'commented' could be a simple flag.



Raphael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080711/c20dfc79/attachment.htm>


More information about the augeas-devel mailing list