restore -o

This commit is contained in:
leaf corcoran 2014-06-19 00:04:10 -07:00
parent 13da7286f8
commit fe2984f85d

View File

@ -118,7 +118,9 @@ local function get_files(fname, files)
return files return files
end end
if opts.h then print_help() end if opts.h then
print_help()
end
if read_stdin then if read_stdin then
local parse = require "moonscript.parse" local parse = require "moonscript.parse"
@ -156,6 +158,10 @@ files = remove_dups(files, function(f)
return f[2] return f[2]
end) end)
if opts.o and #files > 1 then
print_help("-o can not be used with multiple input files")
end
local function get_sleep_func() local function get_sleep_func()
local sleep local sleep
if not pcall(function() if not pcall(function()
@ -271,6 +277,11 @@ if opts.w then
for fname in protected do for fname in protected do
local target = path_to_target(fname, opts.t) local target = path_to_target(fname, opts.t)
if opts.o then
target = opts.o
end
local success, err = compile_and_write(fname, target) local success, err = compile_and_write(fname, target)
if not success then if not success then
io.stderr:write(table.concat({ io.stderr:write(table.concat({
@ -299,6 +310,10 @@ elseif opts.l then
else else
for _, tuple in ipairs(files) do for _, tuple in ipairs(files) do
local fname, target = unpack(tuple) local fname, target = unpack(tuple)
if opts.o then
target = opts.o
end
local success, err = compile_and_write(fname, target) local success, err = compile_and_write(fname, target)
if not success then if not success then
io.stderr:write(fname .. "\t" .. err .. "\n") io.stderr:write(fname .. "\t" .. err .. "\n")