[augeas-devel] Representing and setting a null key
David Lutterkort
lutter at redhat.com
Tue Jul 28 12:16:00 UTC 2009
On Tue, 2009-07-28 at 13:50 +1000, Matt Palmer wrote:
> By leaving the key unspecified in the lens, I can produce this exact tree,
> and that's cool (well, I'd like it if "something" and "else" were keys
> rather than values, but I understand why that isn't practical).
You can create nodes with a null key, but there's no way to access them
afterwards through the API.
As raphink suggested on IRC, the best way to deal with something like
'opt1=val1 opt2 opt3=val2' is to map the opt's to keys in the tree, and
treat the '=valX' as optional values, so that you get a tree like
{ 'opt1' = 'val1' }
{ 'opt2' }
{ 'opt3' = 'val2' }
Depending on how tight you want the lens to be, you can either write it
so that the options that can have values enumerated explicitly, or just
do something very generic like
let opt = [ key key_re . (del /=/ "=" . store value_re)? ]
David
More information about the augeas-devel
mailing list