[augeas-devel] [Augeas] #237: We need a way to comment-out paths

Augeas trac at fedorahosted.org
Mon Nov 21 15:19:13 UTC 2011


#237: We need a way to comment-out paths
--------------------------+-------------------------------------------------
  Reporter:  ptaff        |       Owner:  lutter
      Type:  enhancement  |      Status:  new   
  Priority:  major        |   Milestone:  next  
 Component:  Augeas       |     Version:  0.8.0 
Resolution:               |    Keywords:        
--------------------------+-------------------------------------------------
Comment (by raphink):

 This example might actually be clearer and more complete:

 {{{
 module Comment_Test =

 let eol = Util.eol

 let key_re = /[A-Za-z]+/

 let entry = Build.key_value_line key_re Sep.equal (store Rx.word)

 let comment = [ label "#comment" . del /#[ \t]*/ "# "
               . store (/([^ \t\n].*[^ \t\n]|[^ \t\n])/ - (key_re . "=" .
 Rx.word))
               . eol ]

 let commented = [ del /#[ \t]*/ "# " . Build.xchgs "foo" ".foo"
                       . Sep.equal . store Rx.word . eol ]

 let lns = (entry|comment|commented)*

 let conf = "foo=bar
 #foo=baz
 # This is a comment
 "

 test lns get conf =
   { "foo" = "bar" }
   { ".foo" = "baz" }
   { "#comment" = "This is a comment" }

 test lns put conf after
   rm "/foo";
   set "/.foo" "booz" = "#foo=booz
 # This is a comment
 "
 }}}

 It shows real comments mixed with commented values, and restricts the use
 of hardcoded "foo" to the definition of `commented`.

-- 
Ticket URL: <https://fedorahosted.org/augeas/ticket/237#comment:4>
Augeas <http://augeas.net/>
a configuration API




More information about the augeas-devel mailing list