improve conver_user_opts function readable (#441)
This commit is contained in:
@@ -4,9 +4,12 @@ local extensions = require('telescope._extensions').manager
|
|||||||
local config = require('telescope.config')
|
local config = require('telescope.config')
|
||||||
local command = {}
|
local command = {}
|
||||||
|
|
||||||
|
local arg_value = {
|
||||||
|
['nil'] = nil,['""'] = '',['"'] = ''
|
||||||
|
}
|
||||||
|
|
||||||
local bool_type = {
|
local bool_type = {
|
||||||
['false'] = false,
|
['false'] = false,['true'] = true
|
||||||
['true'] = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- convert command line string arguments to
|
-- convert command line string arguments to
|
||||||
@@ -18,6 +21,7 @@ local function convert_user_opts(user_opts)
|
|||||||
['boolean'] = function(key,val)
|
['boolean'] = function(key,val)
|
||||||
if val == 'false' then
|
if val == 'false' then
|
||||||
user_opts[key] = false
|
user_opts[key] = false
|
||||||
|
return
|
||||||
end
|
end
|
||||||
user_opts[key] = true
|
user_opts[key] = true
|
||||||
end,
|
end,
|
||||||
@@ -25,15 +29,11 @@ local function convert_user_opts(user_opts)
|
|||||||
user_opts[key] = tonumber(val)
|
user_opts[key] = tonumber(val)
|
||||||
end,
|
end,
|
||||||
['string'] = function(key,val)
|
['string'] = function(key,val)
|
||||||
if val == 'nil' then
|
if arg_value[val] ~= nil then
|
||||||
user_opts[key] = nil
|
user_opts[key] = arg_value[val]
|
||||||
end
|
return
|
||||||
if val == '""' then
|
|
||||||
user_opts[key] = ''
|
|
||||||
end
|
|
||||||
if val == '"' then
|
|
||||||
user_opts[key] = ''
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if bool_type[val] ~= nil then
|
if bool_type[val] ~= nil then
|
||||||
user_opts[key] = bool_type[val]
|
user_opts[key] = bool_type[val]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user