-
-
Notifications
You must be signed in to change notification settings - Fork 812
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
repl wanted #79
Comments
This is a very nice feature, I also wanted to add this feature before. I saw the implementation of |
👍 |
I have finished this feature on linux/macosx. (not yet tested it on windows) You can fetch $ xmake lua
> import("core.project.task")
> task.run("hello")
>
> print(path.join("/tmp", "xxx"))
>
> = 1+2+3 / 4
>
> a = 1
> print(a)
>
> for _, v in pairs({1, 2, 3}) do
>> print(v)
>> end |
I think a single val should be printed directly like python:
|
Anyway 👍 |
@titansnow I agree with your point, but I don't know how to distinguish them better in lua. So you need add prefix character '=' to eval expr now.
Or you can help me improve it. interactive.c:168 |
I'd like to look into it 😃 |
I found some info on stackoverflow that might be workable |
lua 5.3 uses pre-check to know whether a statement could const char *retline = lua_pushfstring(L, "return %s;", line);
int status = luaL_loadbuffer(L, retline, strlen(retline), "=stdin");
if (status == LUA_OK) {
// ... at lua.c:334 (5.3.4) if could |
@titansnow I tried this way before, but this method can't handle some function calls well. for example: > import("core.project.task")
> task.run("xxx") <------ will failed, task not found These function calls can also be returned, but |
@waruqi That's too bad 😞 I couldn't figure out why it will be so -- |
@titansnow And it's hard to distinguish whether you want to print the return value. Any function call that has a return value will be printed for example: function test()
-- do some thing
-- ok
return true
end then, we run it using > test()
true -- maybe I don't want to see this return value |
I think now there are two thing needed to be done:
|
@titansnow It try loading > 1 + 2
3
> a = 1
> a
1 But you need assign var manually when call
|
Use the signal to cancel multiline, this way is too much trouble and can not handle the cross-platform well. So you can simply input > for _, v in ipairs({1, 2}) do
>> print(v)
>> q <-- cancel multiline and clear previous input
> 1 + 2
3
I fixed it + extern char* readline (const char*);
+ extern void add_history(const char*); |
👍 |
A very bad message: I tested carefully again, found that although |
@titansnow But it passed on ci.Can you give me some build error info? I try to fix it and detect libreadline . If this library not found, I will continue to uses fgets when building. |
Three solutions:
|
ok, I will fix it in recent days. |
@titansnow I want to use the following two solutions:
|
👌 |
@titansnow Thanks! 😸 |
$ xmake --version
XMake v2.1.4.201705081849, The Make-like Build Utility based on Lua
Copyright (C) 2015-2016 Ruki Wang, tboox.org, xmake.io
Copyright (C) 2005-2015 Mike Pall, luajit.org
$ xmake lua
> os.execv('git',{'--version'})
git version 2.11.0
> os.runv
function: 0xb71601e8
> os.runv('git',{'--version'})
/usr/local/share/xmake/core/base/os.lua:569: runv(git --version) failed(-1)!
stack traceback:
[C]: in function 'error'
/usr/local/share/xmake/core/base/os.lua:569: in function 'raise'
/usr/local/share/xmake/core/sandbox/modules/os.lua:245: in function </usr/local/share/xmake/core/sandbox/modules/os.lua:237>
[C]: in function 'interactive'
...ake/core/sandbox/modules/import/core/sandbox/sandbox.lua:51: in function 'interactive'
/usr/local/share/xmake/plugins/lua/xmake.lua:60: in function </usr/local/share/xmake/plugins/lua/xmake.lua:32>
[C]: in function 'load'
/usr/local/share/xmake/core/project/task.lua:423: in function 'run'
/usr/local/share/xmake/core/main.lua:188: in function </usr/local/share/xmake/core/main.lua:151>
> ? |
@titansnow I have fixed it. |
Feature Request
repl needed to write & test script more easily
That is, each time I wanna do something, for example have a look at
path.join()
, I have to write a simple statement to a file then usexmake lua
to run it. That's troublesome. A repl like other script languages have is good-to-useI tried to impl it by myself but it has trouble with sandbox
The text was updated successfully, but these errors were encountered: