Mercurial Hosting > luan
comparison core/src/luan/cmd_line.luan @ 554:18504c41b0be
move debug() to Io and remove Debug module;
Io.print() now doesn't print newline if there is nothing to be printed;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 18 Jun 2015 03:30:18 -0600 |
parents | 8dcf9e12446b |
children | e25ba7a2e816 |
comparison
equal
deleted
inserted
replaced
553:b1256e2d19a3 | 554:18504c41b0be |
---|---|
1 local Luan = require "luan:Luan" | 1 local Luan = require "luan:Luan" |
2 local ipairs = Luan.ipairs | 2 local error = Luan.error |
3 local load_file = Luan.load_file | 3 local ipairs = Luan.ipairs or error() |
4 local try = Luan.try | 4 local load_file = Luan.load_file or error() |
5 local try = Luan.try or error() | |
5 local Table = require "luan:Table" | 6 local Table = require "luan:Table" |
6 local Io = require "luan:Io" | 7 local Io = require "luan:Io" |
7 local print = Io.print | 8 local print = Io.print or error() |
8 local Debug = require "luan:Debug" | |
9 | 9 |
10 | 10 |
11 local args = {...} | 11 local args = {...} |
12 if #args == 0 then | 12 if #args == 0 then |
13 print(Luan.VERSION) | 13 print(Luan.VERSION) |
14 Debug.debug("> ") | 14 Io.debug("> ") |
15 else | 15 else |
16 local file = args[1] | 16 local file = args[1] |
17 Luan.arg = {} | 17 Luan.arg = {} |
18 for j,v in ipairs(args) do | 18 for j,v in ipairs(args) do |
19 Luan.arg[j-1] = v | 19 Luan.arg[j-1] = v |
20 end | 20 end |
21 try { | 21 try { |
22 function() | 22 function() |
23 local main_file = load_file(file,true) | 23 local main_file = load_file(file,true) |
24 Debug.print_if_something( main_file( Table.unpack(Luan.arg) ) ) | 24 print( main_file( Table.unpack(Luan.arg) ) ) |
25 end; | 25 end; |
26 catch = function(e) | 26 catch = function(e) |
27 -- java(); e.java.printStackTrace(); return | 27 -- java(); e.java.printStackTrace(); return |
28 Io.print_to(Io.stderr, e ) | 28 Io.print_to(Io.stderr, e ) |
29 end; | 29 end; |