瀏覽代碼

[Feature] Selectors: Add `list` generator

tags/2.0
Vsevolod Stakhov 4 年之前
父節點
當前提交
e07897872d
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13
    0
      lualib/lua_selectors.lua

+ 13
- 0
lualib/lua_selectors.lua 查看文件

@@ -38,6 +38,7 @@ local M = "selectors"
local E = {}

local extractors = {
-- Plain id function
['id'] = {
['get_value'] = function(_, args)
if args[1] then
@@ -50,6 +51,18 @@ local extractors = {
For example, `id('Something')` returns a string 'Something']],
['args_schema'] = {ts.string:is_optional()}
},
-- Similar but for making lists
['list'] = {
['get_value'] = function(_, args)
if args[1] then
return fun.map(tostring, args), 'string_list'
end

return {},'string_list'
end,
['description'] = [[Return a list from function's arguments or an empty list,
For example, `list('foo', 'bar')` returns a list {'foo', 'bar'}]],
},
-- Get source IP address
['ip'] = {
['get_value'] = function(task)

Loading…
取消
儲存