diff options
| author | Raphael <glepnir@gopherhub.org> | 2021-01-16 18:55:36 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-16 18:55:36 +0800 |
| commit | c50c69ac0076224bfca90cca68fe480c30671896 (patch) | |
| tree | 2879d45d8397d28059a9953bebd76487b11acd6c /lua | |
| parent | 00e898a1f919a2330c3b0fdf21429627cbaf2175 (diff) | |
support convert custom command arg (#439)
* support convert custom command arg
* format code
* remove unused variable
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/command.lua | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lua/telescope/command.lua b/lua/telescope/command.lua index da67c8b..b94067c 100644 --- a/lua/telescope/command.lua +++ b/lua/telescope/command.lua @@ -4,6 +4,11 @@ local extensions = require('telescope._extensions').manager local config = require('telescope.config') local command = {} +local bool_type = { + ['false'] = false, + ['true'] = true +} + -- convert command line string arguments to -- lua number boolean type and nil value local function convert_user_opts(user_opts) @@ -29,6 +34,9 @@ local function convert_user_opts(user_opts) if val == '"' then user_opts[key] = '' end + if bool_type[val] ~= nil then + user_opts[key] = bool_type[val] + end end } @@ -41,8 +49,10 @@ local function convert_user_opts(user_opts) setmetatable(_switch,_switch_metatable) 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) + else + _switch['string'](key,val) end end end |
