PyInquirer icon indicating copy to clipboard operation
PyInquirer copied to clipboard

Message function definition not working

Open kasperschnack opened this issue 4 years ago • 5 comments

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)

kasperschnack avatar Mar 08 '20 19:03 kasperschnack

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

steele208 avatar Apr 23 '20 10:04 steele208

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.

elyscape avatar Aug 22 '20 04:08 elyscape

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.

nabeelsherazi avatar Nov 13 '20 01:11 nabeelsherazi

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

adamkusmirek avatar May 20 '21 16:05 adamkusmirek

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.

tianshuang avatar Nov 14 '22 02:11 tianshuang