diff options
| author | Raphael <glepnir@gopherhub.org> | 2021-01-17 17:34:58 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-17 17:34:58 +0800 |
| commit | c2039ca78d261392b0ab7bef85b3c5f1c8f507b9 (patch) | |
| tree | 2bf0fb54b3bfc1eda03e3822286009d63f4571f9 /lua/telescope/command.lua | |
| parent | 9f58834d04eca69600c132fe4600bbccf7bb9463 (diff) | |
improve conver_user_opts function readable (#441)
Diffstat (limited to 'lua/telescope/command.lua')
| -rw-r--r-- | lua/telescope/command.lua | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lua/telescope/command.lua b/lua/telescope/command.lua index b94067c..c8d7336 100644 --- a/lua/telescope/command.lua +++ b/lua/telescope/command.lua @@ -4,9 +4,12 @@ local extensions = require('telescope._extensions').manager local config = require('telescope.config') local command = {} +local arg_value = { + ['nil'] = nil,['""'] = '',['"'] = '' +} + local bool_type = { - ['false'] = false, - ['true'] = true + ['false'] = false,['true'] = true } -- convert command line string arguments to @@ -18,6 +21,7 @@ local function convert_user_opts(user_opts) ['boolean'] = function(key,val) if val == 'false' then user_opts[key] = false + return end user_opts[key] = true end, @@ -25,15 +29,11 @@ local function convert_user_opts(user_opts) user_opts[key] = tonumber(val) end, ['string'] = function(key,val) - if val == 'nil' then - user_opts[key] = nil - end - if val == '""' then - user_opts[key] = '' - end - if val == '"' then - user_opts[key] = '' + if arg_value[val] ~= nil then + user_opts[key] = arg_value[val] + return end + if bool_type[val] ~= nil then user_opts[key] = bool_type[val] end |
