InquirerPy
InquirerPy copied to clipboard
Add extra information to Choice
This adds Choice.instruction
.
Supports all prompts that use Choice
.
I've only added support for Alternative Syntax, but am open to adding support for Classic syntax if you'd like.
Closes #55.
@kazhala hate to be a bother, but would you mind giving this PR a look when you get a chance?
@Gracecr this is a nice add. While testing it out it seems that instruction is a required attribute despite it being marked optional?
i.e. if instruction
isn't defined then you end up with a lengthy stack trace error ending in: TypeError: can only concatenate str (not "NoneType") to str
e.g. removing instruction
attribute from the below example results the mentioned error.
from InquirerPy import inquirer
from InquirerPy.base.control import Choice
region = inquirer.select(
message="Select regions:",
choices=[
Choice("ap-southeast-2", name="Sydney", instruction="Region in Australia"),
Choice("ap-southeast-1", name="Singapore", instruction="Region in Southeast Asia"),
],
).execute()
Might be worth looking into?
Strange, I'm not getting the same error. I'm able to run your example code (minus the instruction's) without error:
from InquirerPy import inquirer
from InquirerPy.base.control import Choice
region = inquirer.select(
message="Select regions:",
choices=[
Choice("ap-southeast-2", name="Sydney"),
Choice("ap-southeast-1", name="Singapore"),
],
).execute()
I just tested with py3.7 and py3.10 on windows in CMD. If you don't mind posting your stack trace, perhaps that will help me resolve the issue.
@kazhala any chance you could take a look into this? I find it really helpful