Mercurial Hosting > luan
diff core/src/luan/cmd_line.luan @ 462:2e79b47d02a2
remove all command line options;
add add_extension boolean arg to scheme fns;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 06 May 2015 16:54:20 -0600 |
parents | b31d614343e8 |
children | 8dcf9e12446b |
line wrap: on
line diff
--- a/core/src/luan/cmd_line.luan Wed May 06 14:51:23 2015 -0600 +++ b/core/src/luan/cmd_line.luan Wed May 06 16:54:20 2015 -0600 @@ -1,82 +1,27 @@ local Luan = require "luan:Luan" local ipairs = Luan.ipairs -local load = Luan.load local load_file = Luan.load_file local try = Luan.try -require "luan:String" -- for String methods local Table = require "luan:Table" local Io = require "luan:Io" local print = Io.print local Debug = require "luan:Debug" -local standalone_usage = [=[ -usage: java luan.Luan [options] [script-URI [args]] -Available options are: - -e stat execute string 'stat' - -i enter interactive mode after executing 'script' - -v show version information - -- stop handling options - - stop handling options and execute stdin -]=] - -local function standalone_error(msg) - Io.stderr.write( msg, "\n", standalone_usage ) -end - - local args = {...} -local interactive = false -local showVersion = false -local i = 1 if #args == 0 then - interactive = true - showVersion = true + print(Luan.VERSION) + Debug.debug("> ") else - while i <= #args do - local arg = args[i] - if arg.sub(1,1) ~= "-" or arg == "--" then - break - end - if arg == "-i" then - interactive = true - elseif arg == "-v" then - showVersion = true - elseif arg == "-e" then - i = i + 1 - if i > #args then - standalone_error "'-e' needs argument" - return - end - local cmd = args[i] - local stat = load(cmd,"(command line)",{},true) - local result = Table.pack( stat() ) - if result.n > 0 then - print( Table.unpack(result,1,result.n) ) - end - elseif arg == "-" then - local src = Io.stdin.read_text() - local stdin = load(src,"stdin") - stdin() - return - else - standalone_error( "unrecognized option '"..arg.."'" ) - return - end - i = i + 1 - end -end -if showVersion then print(Luan.VERSION) end -if i <= #args then - local file = args[i] + local file = args[1] Luan.arg = {} for j,v in ipairs(args) do - Luan.arg[j-i] = v + Luan.arg[j-1] = v end try { function() - local main_file = load_file(file..".luan") - main_file( Table.unpack(Luan.arg) ) + local main_file = load_file(file,true) + Debug.print_if_something( main_file( Table.unpack(Luan.arg) ) ) end; catch = function(e) -- java(); e.printStackTrace(); return @@ -84,6 +29,3 @@ end; } end -if interactive then - Debug.debug("> ") -end