I'm trying to write a lens for modules.autoload.d which seems to be going
well.  I'm trying to figure out how I can have a sequence re-start its
numbering or new sub-trees; this is the test-case I'm referring to:

Test result: modulesautoload.aug:39.2-.56:
  { "ip_gre"
    { "1"
      { "option1" = "a" }
    }
  }
  { "8021q"
    { "2"
      { "option2" = "b" }
    }
  }

I would expect the '2' for the "8021q" sub-tree to be a "1" since its the
first option for that sub-tree.

My lens is attached; let me know if you don't receive it.

-Doug
(* Parsing /etc/modules.autoload.d/* *)

module ModulesAutoload=
  autoload xfm

  let sep_tab = Util.del_ws_tab
  let sep_spc = Util.del_ws_spc

  let eol = del /[ \t]*\n/ "\n"
  let indent = del /[ \t]*/ ""
  let s = del /[ \t]+/ " "

  let comment = Util.comment
  let word = /[0-9A-Za-z_-]+/
  let optword = /[^ \t\n#:]+/
  let empty   = [ del /[ \t]*#?[ \t]*\n/ "\n" ]

  let opt = store word
  let optval = [ key word . del /=/ "=" . store optword ]

(*
  let record = [ seq "moduleline"
                 . [ label "modulename" . store word ]
                 . [ label "option" . s . store word ]*
                 . (comment|eol) ]
*)
  let record = [ key word .
                 [ seq "option" . s . ( opt | optval ) ]* .
                 eol ]

  let lns = ( empty | comment | record ) *

  test lns get "ip_gre\n" = ?
  test lns get "ip_gre option1\n" = ?
  test lns get "ip_gre option1=a\n" = ?
  test lns get "ip_gre option1=a option2\n" = ?
  test lns get "ip_gre option1=a option2=b\n" = ?
  test lns get "ip_gre option1=a option2 option3=c\n" = ?
  test lns get "ip_gre option1=a\n8021q option2=b\n" = ?

  let xfm = transform lns (
    incl "/etc/modules.autoload.d/*" .
    Util.stdexcl
  )

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to