support convert custom command arg (#439)

* support convert custom command arg

* format code

* remove unused variable
This commit is contained in:
Raphael
2021-01-16 18:55:36 +08:00
committed by GitHub
parent 00e898a1f9
commit c50c69ac00

View File

@@ -4,6 +4,11 @@ local extensions = require('telescope._extensions').manager
local config = require('telescope.config') local config = require('telescope.config')
local command = {} local command = {}
local bool_type = {
['false'] = false,
['true'] = true
}
-- convert command line string arguments to -- convert command line string arguments to
-- lua number boolean type and nil value -- lua number boolean type and nil value
local function convert_user_opts(user_opts) local function convert_user_opts(user_opts)
@@ -29,6 +34,9 @@ local function convert_user_opts(user_opts)
if val == '"' then if val == '"' then
user_opts[key] = '' user_opts[key] = ''
end end
if bool_type[val] ~= nil then
user_opts[key] = bool_type[val]
end
end end
} }
@@ -41,8 +49,10 @@ local function convert_user_opts(user_opts)
setmetatable(_switch,_switch_metatable) setmetatable(_switch,_switch_metatable)
for key,val in pairs(user_opts) do for key,val in pairs(user_opts) do
if default_opts[key] ~= nil then if default_opts[key] ~= nil then
_switch[type(default_opts[key])](key,val) _switch[type(default_opts[key])](key,val)
else
_switch['string'](key,val)
end end
end end
end end