kazhala / InquirerPy

:snake: Python port of Inquirer.js (A collection of common interactive command-line user interfaces)
https://inquirerpy.readthedocs.io
MIT License
351 stars 20 forks source link

where is when for inquirer? #47

Closed mr-ice closed 2 years ago

mr-ice commented 2 years ago

When using inquirer, there doesn't appear to be a when. I was pretty happy with the Alternate scheme until I uncovered when was missing.

The Alternate had the extra information and 'mutliline' where the Classic does not appear to have those at all. Classic is also missing 'editor' from PyInquirer which is another way to get multiline.

I need both 'when' and 'multiline'.

Is when a pretty big change since you don't tend to have the context of previous answers to pass to the when expression?

Is multiline easy to add to Classic?

Is it possible to mix and match in the questions list? I suppose I should try that on my own :) But it would probably be helpful if prompt would call .execute() on any inquirer objects it found so that could be one workaround. It would probably need a 'name' though to save the answers in the object (or use an auto-index).

kazhala commented 2 years ago

Hi @mr-ice ,

I'm putting less development effort on the Classic version to encourage people to use the Alternate syntax. Editor prompt is not ported and I don't have plans to support it for now sorry.

The reason I didn't add a when feature in alternate syntax is you can simply add if conditions to check previous results to conditionally run the next question, which would also make the code more readable.

multiline is supported by Classic syntax.

from InquirerPy import prompt

def main():
    questions = [
        {
            "type": "input",
            "message": "Enter your name:",
            "multiline": True,
            "instruction": "ESC + Enter to finish input",
        }
    ]
    result = prompt(questions)

if __name__ == "__main__":
    main()

For your last point, I'm thinking to add a session object to store some common parameters so that you don't have to repeatedly provide them.

Hope the information solves your concern. Feel free to re-open this issue.

Thanks, Kevin