checkbox¶
Hook for PyInquirer checkbox
type prompts. Allows the user to multi-select from a list of choices and outputs a list. Takes in three forms of choices
inputs. A list of string, a list of maps with all keys having a name
field per the original spec, or list of maps with the key as the question, the value as the output.
Inputs¶
Name | Type | Default | Required | Description |
---|---|---|---|---|
message | str | None | False | String message to show when prompting. |
choices | Union[list[str], list[dict]] | True | Either a list of strings or dictionary . | |
checked | bool | False | True | Boolean if the default choices should all be checked. |
index | bool | False | True | Boolean to return the index instead of the answer |
fuzzy | bool | False | True | Allow fuzzy search like fzf - docs |
Arguments¶
Position | Argument | Type |
---|---|---|
1 | message | str |
Returns¶
list
Examples¶
The basic versions of the checkbox
hook can be called in these ways
compact->: checkbox "What do you want?" ['stuff','things']
expanded:
->: checkbox
choices:
- stuff
- things
? What do you want? done (2 selections)
? expanded >>> (<up>, <down> to move, <space> to select, <a> to toggle, <i> to invert)
❯○ stuff
● things
compact:
- stuff
- things
expanded:
- things
Other versions can use custom prompts for the choices and output the key.
selection:
->: checkbox
message: What you do?
checked: true
choices:
- I do stuff: stuff
- I do things: things
selection:
- stuff
- things