Skip to content

Commit

Permalink
Merge pull request #5297 from myk002/myk_boolean
Browse files Browse the repository at this point in the history
[argparse] improve error message when boolean arg is missing
  • Loading branch information
myk002 authored Feb 22, 2025
2 parents 9e7d2d9 + c025282 commit 0c6da54
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/lua/argparse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ local toBool={["true"]=true,["yes"]=true,["y"]=true,["on"]=true,["1"]=true,["ena
---@param arg_name? string
---@return boolean
function boolean(arg, arg_name)
if arg == nil then
arg_error(arg_name, 'missing value; expected "true", "yes", "false", or "no"')
end
local arg_lower = string.lower(arg)
if toBool[arg_lower] == nil then
arg_error(arg_name,
Expand Down

0 comments on commit 0c6da54

Please sign in to comment.