summaryrefslogtreecommitdiff
path: root/yazi-enter.yazi/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'yazi-enter.yazi/main.lua')
-rw-r--r--yazi-enter.yazi/main.lua13
1 files changed, 12 insertions, 1 deletions
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