-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathappend.lua
39 lines (35 loc) · 1004 Bytes
/
append.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local parser = require("overseer.parser")
local Append = {
desc = "Append the current item to the results list",
long_desc = "Normally the 'extract' node appends for you, but in cases where you use extract with `append = false`, you can explicitly append without extracting using this node.",
doc_args = {
{
name = "opts",
type = "object",
desc = "Configuration options",
position_optional = true,
fields = {
{
name = "postprocess",
type = "function",
desc = "Call this function to do post-extraction processing on the values",
},
},
},
},
}
function Append.new(opts)
opts = opts or {}
return setmetatable({
postprocess = opts.postprocess,
}, { __index = Append })
end
function Append:reset() end
function Append:ingest(line, ctx)
if self.postprocess then
self.postprocess(ctx.item, ctx)
end
parser.util.append_item(true, line, ctx)
return parser.STATUS.SUCCESS
end
return Append