CITGuru / PyInquirer

A Python module for common interactive command line user interfaces
MIT License
1.92k stars 236 forks source link

`"checked": True` only works when all of the choices are `"checked": True` #51

Closed tjb1982 closed 5 years ago

tjb1982 commented 5 years ago

For something like this:

{
    "type": "checkbox",
    "name": "items",
    "message": "Select items",
    "choices": get_choices(app_state, items),
}

where choices is made up of a list such as

def get_choices(app_state, items):
    return [
        {
            "name": "<item name=\"{}\" created=\"{}\">".format(x["name"], x["created"]),
            "value": x["name"],
            "checked": x["name"] in app_state["collections"],
        } for x in items
    ]

If checked is False for any of the choices, it displays all of the choices as if they were "checked": False, unless the value entry is removed and the name entry is x["name"].