[augeas-devel] making a new lense, having a weird matching issue

Raphaël Pinson raphael.pinson at camptocamp.com
Tue Feb 11 22:04:17 UTC 2014


Hello,

On Tue, Feb 11, 2014 at 10:18 PM, Pat Riehecky <riehecky at fnal.gov> wrote:

> I'm certainly overlooking something obvious, but.....
>
> Here is a way slimmed down version....
>
> Can I get a quick hand un-sticking my brain?
>
> my config file is:
>
> makestep 10 3
>
>
> It is the only line and it may or may not be followed by a comment.
>
> the '10' is a threshold and the '3' an upper limit
>
> My current (edited) stab at this is mylense.aug:
>
> module Mylense =
>   autoload xfm
>
> let val_sep = Util.del_ws_spc
>
> let makestep = [ val_sep . key /makestep/ . val_sep .
>                       [ label "threshold" . store Rx.integer ] .
>

Your first issue is here. You're missing a space between your two values.



>                       [ label "limit" . store Rx.integer ] ] .
>                       Util.comment_or_eol
>


This would be a second issue. Util.comment_or_eol needs to be part of the
makestep node, otherwise it will clash with Util.empty and Util.comment.

All in all, here's my take on your lens:


module Mylense =
  autoload xfm

(* Use Util.indent for indentation.
      It's identical to an opt_space, but easier to understand *)
let makestep = [ Util.indent . key "makestep"
               . Sep.space
               . [ label "threshold" . store Rx.integer ]
               . Sep.space
               . [ label "limit" . store Rx.integer ]
               . Util.comment_or_eol ]

let lns = ( Util.empty | Util.comment | makestep )*

let filter = (incl "/tmp/testfile")

let xfm = transform lns filter

(* Put the tests in a test file eventually *)
test lns get "makestep 10 3\n" =
  { "makestep"
    { "threshold" = "10" }
    { "limit" = "3" } }

test lns get "makestep 10 3   # a comment\n" =
  { "makestep"
    { "threshold" = "10" }
    { "limit" = "3" }
    { "#comment" = "a comment" } }


-- 
Raphaël Pinson
Infrastructure Developer & Trainer
+33 479 26 57 93
+33 781 90 00 79

Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20140211/392e1ea4/attachment.htm>


More information about the augeas-devel mailing list