tmbo / questionary

Python library to build pretty command line user prompts ✨Easy to use multi-select lists, confirmations, free text prompts ...
MIT License
1.53k stars 87 forks source link

Refer to a previous answer as the default value of the next question #358

Open tapyu opened 8 months ago

tapyu commented 8 months ago

Describe the problem

Consider the following problem

answers = questionary.form(
    first = questionary.text("Hi?"),
    second = questionary.text("Hi again?", default=lambda x: x['first'])
).ask()

Describe the solution

I would like that the answer of the previous question were the default value of the next question. AFAIK, questionary doesn't have this feature.

kiancross commented 2 months ago

This option is not possible. However, if you look at the source for form, you will see it is very easy to adapt to add what you desire: it's just looping through the questions.

https://github.com/tmbo/questionary/blob/89758d2897734619f879c1007a79247c36493684/questionary/form.py#L60