Differences From
Artifact [49c267b075]:
21 21 for o,desc in pairs(tbl) do
22 22 local consume = desc.consume or 0
23 23 local incr = desc.inc or 0
24 24 options.entries[#options.entries + 1] = {
25 25 field = o, type = (consume > 0) and &rawstring or
26 26 (incr > 0) and uint or bool
27 27 }
28 - helpstr = helpstr .. string.format(' -%s --%s: %s\n',
29 - desc[1], sanitize(o), desc[2])
28 + if desc[1] then
29 + helpstr = helpstr .. string.format(' -%s --%s: %s\n',
30 + desc[1], sanitize(o), desc[2])
31 + else
32 + helpstr = helpstr .. string.format(' --%s: %s\n',
33 + sanitize(o), desc[2])
34 + end
30 35 end
31 36 for o,desc in pairs(tbl) do
32 37 local flag = desc[1]
33 38 local consume = desc.consume or 0
34 39 local incr = desc.inc or 0
35 40 init[#init + 1] = quote [self].[o] = [
36 41 (consume > 0 and `nil) or
................................................................................
48 53 end
49 54 end
50 55 elseif incr > 0 then
51 56 ch = quote [self].[o] = [self].[o] + incr end
52 57 else ch = quote
53 58 [self].[o] = true
54 59 end end
55 - shortcases[#shortcases + 1] = quote
56 - case [int8]([string.byte(flag)]) then [ch] end
60 + if flag ~= nil then
61 + shortcases[#shortcases + 1] = quote
62 + case [int8]([string.byte(flag)]) then [ch] end
63 + end
57 64 end
58 65 longcases[#longcases + 1] = quote
59 66 if lib.str.cmp([arg]+2, [sanitize(o)]) == 0 then [ch] goto [skip] end
60 67 end
61 68 end
62 69 terra options:free() self.arglist:free() end
63 70 options.methods.parse = terra([self], [argc], [argv])