From c50c69ac0076224bfca90cca68fe480c30671896 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 16 Jan 2021 18:55:36 +0800 Subject: [PATCH] support convert custom command arg (#439) * support convert custom command arg * format code * remove unused variable --- lua/telescope/command.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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