Skip to content

Commit

Permalink
if use() is passed a file, uses that. If it's passed nil as the buffe…
Browse files Browse the repository at this point in the history
…r, it uses stdin
  • Loading branch information
geoffleyland committed Jun 19, 2014
1 parent 8db3740 commit 3b28558
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/csv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,17 @@ buffer_mt.__index = buffer_mt


local function use(buffer, parameters)
parameters = parameters or {}
parameters.filename = parameters.filename or "<unknown>"
parameters.column_map = parameters.columns and
column_map:new(parameters.columns)

if not buffer then
buffer = file_buffer:new(io.stdin)
elseif io.type(buffer) == "file" then
buffer = file_buffer:new(buffer)
end

local f = { buffer = buffer, parameters = parameters }
return setmetatable(f, buffer_mt)
end
Expand Down

0 comments on commit 3b28558

Please sign in to comment.