Open Atcold opened 8 years ago
OK, found the bug. It's about the help
field. If it is not specified, everything works as expected
th> check = argcheck{
{name="x", type="number", default=0, help="the age of the captain"},
{name="msg", type="string", help="a message"}
}
[0.0010s]
th> check(4)
[string "argcheck"]:74:
Arguments:
({
[x = number] -- the age of the captain [default=0]
msg = string -- a message
})
Got: number
invalid arguments!
stack traceback:
[C]: in function 'error'
[string "argcheck"]:74: in function 'check'
[string "_RESULT={check(4)}"]:1: in main chunk
[C]: in function 'xpcall'
/Users/atcold/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
...cold/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x010ca74630
[0.0005s]
If it is specified, then it breaks without knowledge of what went wrong
th> check = argcheck{
help=[[
This function is going to do a simple addition.
Give a number, it adds 5. Amazing.
]],
{name="x", type="number", default=0, help="the age of the captain"},
{name="msg", type="string", help="a message"}
}
[0.0012s]
th> check(4)
[string "argcheck"]:74:
This function is going to do a simple addition. Give a number, it adds 5.
Amazing.
Got: number
invalid arguments!
stack traceback:
[C]: in function 'error'
[string "argcheck"]:74: in function 'check'
[string "_RESULT={check(4)}"]:1: in main chunk
[C]: in function 'xpcall'
/Users/atcold/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
...cold/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x010ca74630
[0.0006s]
In the documentation we have
in my terminal I get
\n
is ignored.Also
? addfive
does not show the documentation. How do I get to see it?In the same way, for the multi argument case, on the documentation it's shown that one may expect an explanation like the following
where one knows that
msg
does not have any default value, but what I get instead is