comparison core/src/luan/cmd_line.luan @ 320:fed1893821bf

remove global namespace git-svn-id: https://luan-java.googlecode.com/svn/trunk@321 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 06 Feb 2015 21:54:41 +0000
parents 1f6d828986b9
children 7f7708e8fdd4
comparison
equal deleted inserted replaced
319:f6db49c294a7 320:fed1893821bf
1 import "luan:Luan"
1 import "luan:String" 2 import "luan:String"
2 import "luan:Table" 3 import "luan:Table"
3 import "luan:Io" 4 import "luan:Io"
4 import "luan:Debug" 5 import "luan:Debug"
6
7 local ipairs = Luan.ipairs
8 local load = Luan.load
9 local load_file = Luan.load_file
5 10
6 11
7 local standalone_usage = [=[ 12 local standalone_usage = [=[
8 usage: java luan.Luan [options] [script [args]] 13 usage: java luan.Luan [options] [script [args]]
9 Available options are: 14 Available options are:
61 end 66 end
62 end 67 end
63 if showVersion then print(_VERSION) end 68 if showVersion then print(_VERSION) end
64 if i <= #args then 69 if i <= #args then
65 local file = args[i] 70 local file = args[i]
66 _G.arg = {} 71 local arg = {}
67 for j,v in ipairs(args) do 72 for j,v in ipairs(args) do
68 _G.arg[j-i] = v 73 arg[j-i] = v
69 end 74 end
70 try 75 try
71 local main_file = load_file("file:"..file) 76 local main_file = load_file("file:"..file)
72 main_file( Table.unpack(_G.arg) ) 77 main_file( Table.unpack(arg) )
73 catch e do 78 catch e do
74 Io.print_to(Io.stderr, e ) 79 Io.print_to(Io.stderr, e )
75 end 80 end
76 end 81 end
77 if interactive then 82 if interactive then