Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra information to Choice #56

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Gracecr
Copy link

@Gracecr Gracecr commented Feb 13, 2023

This adds Choice.instruction.

tmp2

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.

@Gracecr
Copy link
Author

Gracecr commented Apr 26, 2023

@kazhala hate to be a bother, but would you mind giving this PR a look when you get a chance?

@exastone
Copy link

@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?

@Gracecr
Copy link
Author

Gracecr commented Oct 3, 2023

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.

brodybits added a commit to brodybits/InquirerLib that referenced this pull request Jan 16, 2024
Including some proposed & unpublished updates from InquirerPy:

- kazhala/InquirerPy#69 - fix typos
- kazhala/InquirerPy#65 - add DataValidator class
- kazhala/InquirerPy#56 - add Choice.instruction field
- kazhala/InquirerPy#52 - proper exporting of functions ref:
  - kazhala/InquirerPy#60
  - kazhala/InquirerPy#48

also document some info to address issue: kazhala/InquirerPy#64
@lt-mayonesa
Copy link

@kazhala any chance you could take a look into this? I find it really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra choice info for select/fuzzy
3 participants