CITGuru / PyInquirer

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

Choices should accept callable to generate options #9

Closed bmwant closed 5 years ago

bmwant commented 5 years ago

Description

choices field on questions should accept a callable as documentation states.

Changes

CITGuru commented 5 years ago

I guess its already supported. You can call a method to generate choices. So what are you trying to say?

bmwant commented 5 years ago

@CITGuru yes, you can call a function, but there is no ability to make choices dynamic based on previous answers. I want to limit (or extend) options based on previously provided answers to make workflow more flexible.

bmwant commented 5 years ago
> how many choices you want to have in the next question? [1, 5]
> function receives previous answers and returns range(answers['size'])

Is there an ability to produce such a behaviour with current code?

bmwant commented 5 years ago

@CITGuru please let me know whether this change is feasible for current repo. I need to base another library on this code, so probably will need to use my own fork if this change will not go into any release. Any feedback is appreciated too.

CITGuru commented 5 years ago

Okay, this might go into dev release for the main time before its pushed to pypi. I'll work on it.

cyberbeast commented 5 years ago

Any updates on this? I am looking for this exact functionality. Also, thank you for this @CITGuru :)