From 60f62b6168269e895972acebf7ae20e3ba4ea821 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Sat, 5 Sep 2026 13:56:04 +0200 Subject: Reject unknown invocation options --- yazi-enter.yazi/main.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'yazi-enter.yazi') diff --git a/yazi-enter.yazi/main.lua b/yazi-enter.yazi/main.lua index f4f4333..ccee0d7 100644 --- a/yazi-enter.yazi/main.lua +++ b/yazi-enter.yazi/main.lua @@ -1,5 +1,11 @@ --- @since 26.9.1 +local ACCEPTED_OPTIONS = { + previous = true, + smart = true, + insensitive = true, +} + local function parse_mode(value) if value == "directory" or value == "file" or value == "either" then return value @@ -27,8 +33,13 @@ end local function validate_argument_keys(args) for key in pairs(args) do - if type(key) == "number" and key ~= 1 then + local key_type = type(key) + if key_type == "number" and key ~= 1 then error(("yazi-enter: unexpected positional argument at index %s"):format(key), 0) + elseif key_type == "string" and not ACCEPTED_OPTIONS[key] then + error(("yazi-enter: unknown option --%s"):format(key), 0) + elseif key_type ~= "number" and key_type ~= "string" then + error("yazi-enter: argument keys must be positional indexes or option names", 0) end end end -- cgit v1.2.3