Skip to content

help text output breaks if you use boolean choices on options #29

@TangentFoxy

Description

@TangentFoxy

When I use the following:

local argparse = require "argparse"
local parser = argparse()
parser:option("--interactive", "Wait for user input.", true):choices{true, false}
local args = parser:parse()

Everything appears to work fine unless I use the built-in -h or --help to display help text, which returns:

luajit: ./argparse.lua:497: invalid value (boolean) at index 1 in table for 'concat'
stack traceback:
	[C]: in function 'concat'
	./argparse.lua:497: in function '_get_default_argname'
	./argparse.lua:487: in function '_get_argname'
	./argparse.lua:376: in function '_get_argument_list'
	./argparse.lua:576: in function '_get_usage'
	./argparse.lua:753: in function 'add_element'
	./argparse.lua:783: in function 'get_usage'
	./argparse.lua:1003: in function 'get_help'
	./argparse.lua:233: in function 'action'
	./argparse.lua:1793: in function 'close'
	./argparse.lua:1722: in function 'invoke'
	./argparse.lua:1906: in function 'invoke'
	./argparse.lua:2025: in function 'parse'
	./installer.lua:17: in main chunk
	[C]: at 0x57c0bf72e0c0

Using a boolean default doesn't cause this error, but the choices appear to cause the problem.

(Edited to fix an error in my usage that is unrelated to this bug.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions