comparison src/luan/tools/cmd_line.luan @ 136:7e160d2f6d9c

update HttpLib, untested git-svn-id: https://luan-java.googlecode.com/svn/trunk@137 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 11 Jun 2014 09:33:02 +0000
parents 98aba462c422
children
comparison
equal deleted inserted replaced
135:3119326260ea 136:7e160d2f6d9c
36 if i == #args then 36 if i == #args then
37 standalone_error "'-e' needs argument" 37 standalone_error "'-e' needs argument"
38 return 38 return
39 end 39 end
40 local cmd = args[i] 40 local cmd = args[i]
41 local fn = load(cmd,"(command line)",true,true) 41 local stat = load(cmd,"(command line)",true,true)
42 local result = Table.pack( fn() ) 42 local result = Table.pack( stat() )
43 if result.n > 0 then 43 if result.n > 0 then
44 print( Table.unpack(result,1,result.n) ) 44 print( Table.unpack(result,1,result.n) )
45 end 45 end
46 elseif arg == "-" then 46 elseif arg == "-" then
47 local src = Io.stdin.read_text() 47 local src = Io.stdin.read_text()
48 local fn = load(src,"stdin") 48 local stdin = load(src,"stdin")
49 fn() 49 stdin()
50 return 50 return
51 else 51 else
52 standalone_error( "unrecognized option '"..arg.."'" ) 52 standalone_error( "unrecognized option '"..arg.."'" )
53 return 53 return
54 end 54 end
60 local file = args[i] 60 local file = args[i]
61 _G.arg = {} 61 _G.arg = {}
62 for j,v in ipairs(args) do 62 for j,v in ipairs(args) do
63 _G.arg[j-i] = v 63 _G.arg[j-i] = v
64 end 64 end
65 local fn = load_file(file) 65 local main_file = load_file(file)
66 fn( Table.unpack(_G.arg) ) 66 main_file( Table.unpack(_G.arg) )
67 end 67 end
68 if interactive then 68 if interactive then
69 Debug.debug("> ") 69 Debug.debug("> ")
70 end 70 end