-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Lua interpreter in augtool #300
base: master
Are you sure you want to change the base?
Conversation
cbaa9c4
to
fad7fee
Compare
I kind of fixed the multiline lua REPL problem, irb-style. The implementation might not be perfect, but it works:
|
@ncopa since you wrote the bindings for lua, do you have an opinion on this? |
what is the benefit with embedding lua into augeas instead of just using lua-augeas module? |
4512e56
to
de3b4a5
Compare
@ncopa most users (at least sysadmins) will not want to install a lua interpreter (if they know it exists), the lua bindings for Augeas, and write a script that sets up a handler (if they know how that works), but they need to be able to perform operations and loop in the code they use in augtool The idea here is that you can simply install The typical use I'm thinking of is setting up docker containers using augtool-based scripts. |
I really like the idea of having some sort of standard scripting language readily available when you install augeas - and lua seems to be a great fit for that. This is awesome stuff. I am not 100% sold on whether that should be part of augtool or a separate tool - I need to understand the tradeoffs better in terms of platform suppport, addl dependencies, and (maybe) size. I am not against it, just that I need a clearer picture of these things. Also: if we ship with lua support by default, wouldn't we also want some sort of basic lua scripts/libraries, i.e. the ability to ship conveniences in lua, basically things that either make working with the augeas API easier from lua, or that give you canned answers for common tasks ? That doesn't have to happen right off the bat, but is something to keep in mind as this evolves. |
Thanks for reviewing @lutter. From what I can see, Lua supports at least as many platforms as we do (Unix + Windows). It is known for being not only embeddable, but also very light. I've tried building Augeas statically to compare, but there is a local definition of As for external Lua libraries, I believe you should be able to use |
I commented out the definition of
So Lua support adds 33602 (32K) to the static binary. |
@@ -69,4 +69,6 @@ AUGEAS_0.18.0 { | |||
AUGEAS_0.20.0 { | |||
global: | |||
aug_escape_name; | |||
luaopen_augeas; | |||
aug_lua; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has there been no release since your patch?
i.e.: shouldn't this be 0.21.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that was a testing thing. I guess this entry also depends on whether we expose aug_lua
I would like to merge the majority of this with https://github.com/ncopa/lua-augeas/blob/master/laugeas.c into a common C file. Then we could have a separate make target for a lua module, so we could build the lua-augeas directly from the augeas sources, in addition to the lua embedded stuff. |
@ncopa which parts exactly would you like to merge into lua-augeas? |
Rebased on master |
@raphink I understand ncopa's comment such that there is a considerable overlap between your auglua.c and his laugeas.c. He would like to abolish his lua-augeas project and build the Lua bindings from the Augeas source tree in future. |
I understand that... I don't have much time for that (or extended knowledge of Lua), but I have several projects that would benefit from lua integration in augtool... |
@ncopa do you have some time maybe to help me implement that properly? |
This commit adds a -l/--lua flag to augtool which allows to execute Lua code instead of the native augsrun interpreter. Each API call is mapped into a correponding aug_* Lua command, as well as short * commands.
@kunkku there is already a lua-augeas project, but the goal here is really to embed lua in augtool. |
combine auglua and lua-augeas implementations
@kunkku just added commits to this PR (thank you). |
fix compilation on musl libc
include config.h in auglua.c and luamod.c
I've recently started playing with mruby and really like it. I ported the ruby bindings over to it All of this makes me wonder if an mruby-based command line tool might not be a better option, as it seems a lot more people are familiar with that than with Lua. To give you some impression of what that looks like, this is an example of using mruby with augeas |
I've seen lua in a lot of projects, but never mruby, so i can't really tell. I guess all that matters would be to bring higher level language into augeas itself. |
This PR adds a
-l
/--lua
flag to augtool which allows to code in Lua instead of the native augrun interpreter.Examples can be found in
tests/test.auglua
.Current shortcomings:
aug_close
andlua_close
somewherequit
is not recognized in Lua mode, but ^D worksauglua.c
file for a cleaneraugtool.c
Do we want to call all functionsI'm actually declaring a global tableaug_*
or simply*
(such asset
,get
, etc.) so they behave like the augrun interface? So far, I'm doing both...aug
and assigning all functions to it nowExample script that reimplements augeasproviders_shellvar in lua: https://gist.github.com/raphink/4fcb67ae9b56675e76a8
@lutter @domcleal what's your take on this?