diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-05 13:56:04 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-05 13:56:04 +0200 |
| commit | 60f62b6168269e895972acebf7ae20e3ba4ea821 (patch) | |
| tree | 665521180778b1b3ebe2d879fb414c42a7b76b46 | |
| parent | 474a3ade88a2d3d81afa44c1edcd5c506b922c83 (diff) | |
Reject unknown invocation options
| -rw-r--r-- | yazi-enter.yazi/main.lua | 13 |
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 |