Mercurial Hosting > luan
diff src/luan/cmd_line.luan @ 775:1a68fc55a80c
simplify dir structure
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 26 Aug 2016 14:36:40 -0600 |
parents | core/src/luan/cmd_line.luan@3e30cf310e56 |
children | d6d0bd05ad8c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/luan/cmd_line.luan Fri Aug 26 14:36:40 2016 -0600 @@ -0,0 +1,31 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local ipairs = Luan.ipairs or error() +local load_file = Luan.load_file or error() +local try = Luan.try or error() +local Table = require "luan:Table.luan" +local Io = require "luan:Io.luan" +local print = Io.print or error() + + +local args = {...} +if #args == 0 then + print("Luan "..Luan.VERSION) + Io.debug("> ") +else + local file = args[1] + Luan.arg = {} + for j,v in ipairs(args) do + Luan.arg[j-1] = v + end + try { + function() + local main_file = load_file(file) + print( main_file( Table.unpack(Luan.arg) ) ) + end; + catch = function(e) +-- java(); e.java.printStackTrace(); + Io.print_to(Io.stderr, e ) + end; + } +end