CITGuru / PyInquirer

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

Message function definition not working #96

Open kasperschnack opened 4 years ago

kasperschnack commented 4 years ago

Thank you for this! It's a lot of fun to work with! I tried creating a function for the message to return a string but functions for message doesn't seem to be working (even though docs say otherwise).

def _confirm_options(answers):
    message = "Confirm choices: " + str(answers)
    return message

group_choices = [
    {
        "type": "input",
        "name": "group_id",
        "message": "Enter id of parent group",
    },
    {
        "type": "input", 
        "name": "group_name", 
        "message": "Enter desired group name"},
    {
        "type": "confirm",
        "name": "confirm",
        "message": _confirm_options,
        "default": True,
    },
]

result is this: ? <function at 0x10f287a60> (Y/n)

steele208 commented 4 years ago

I'm running into the same issue - any light you can shed?

elyscape commented 3 years ago

It looks like there's no check whether the value of messages is callable and subsequent call. By contrast, contrast is documented similarly but the function is actually called. There is no similar code for messages in the codebase. Duplicating this code and replacing all mentions of choices with messages would fix this.

nabeelsherazi commented 3 years ago

Just ran into the same issue. Thanks @elyscape for showing the solution. It took about a minute to fix -- now the hard part is just getting it pulled in lol. In the meanwhile, I'm using my own branch as a local package.

adamkusmirek commented 3 years ago

Any progress on this getting pulled in? Ran into it as well and it would be nice not to have maintain my own fork...

tianshuang commented 1 year ago

Any progress on this getting pulled in? Ran into it as well and it would be nice not to have maintain my own fork...

This project appears to be no longer active.