[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: DSL in lua
- From: Dirk Laurie <dirk.laurie@...>
- Date: Thu, 6 Dec 2012 08:27:02 +0200
You're a few commas away from legal Lua syntax.
directory "/etc/" {
owner "root",
group "wheel",
mode "0755",
action "create",
}
It can be done (functions owner etc would have to store
their argument somewhere) but a few equal signs makes the
Lua code efficient:
directory "/etc/" {
owner="root",
group="wheel",
mode="0755",
action="create",
}
The code would be (not tested):
function directory(dirname)
return function(t)
os.execute ("mkdir %s; chown %s.%s %s; chmod %s %s"):
format(dirname,t.owner,t.group,dirname,t.mode,dirname)
end
end
Or one could replace the `{`..`}` by `[[`..`]]` and insert
a small parser that extracts the fields from the string.