Closed stephenmw closed 5 months ago
The documentation says it should behave the same as flag:parse
which does not allow $nil
as a default value:
elvish> flag:parse [-port 1] [[port $nil 'port number']]
Exception: bad value: flag default value must be boolean, number, string or list, but is $nil
[tty 12]:1:1: flag:parse [-port 1] [[port $nil 'port number']]
elvish> flag:parse [-port 1] [[port 0 'port number']]
▶ [&port=1]
▶ []
Fixing this is trivial. It simply requires replacing
addFlag(fs, name, value, "")
with
if err := addFlag(fs, name, value, ""); err != nil {
return err
}
to match the same behavior as flag:parse
.
flag::call fails to find options with a default of $nil. Any other default works. A minimal example: