Skip to content

Commit 0c6da54

Browse files
authored
Merge pull request #5297 from myk002/myk_boolean
[argparse] improve error message when boolean arg is missing
2 parents 9e7d2d9 + c025282 commit 0c6da54

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/lua/argparse.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ local toBool={["true"]=true,["yes"]=true,["y"]=true,["on"]=true,["1"]=true,["ena
244244
---@param arg_name? string
245245
---@return boolean
246246
function boolean(arg, arg_name)
247+
if arg == nil then
248+
arg_error(arg_name, 'missing value; expected "true", "yes", "false", or "no"')
249+
end
247250
local arg_lower = string.lower(arg)
248251
if toBool[arg_lower] == nil then
249252
arg_error(arg_name,

0 commit comments

Comments
 (0)