You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thanks for creating/maintaining questionary! This is a super useful package.
I'm working on using questionary to create an interactive "wizard" for configuring a fairly complex click CLI app (osxphotos]. I'd like the output of the questions to map directly to the input needed to configure the app. I'd really like to do this using the prompt() function to pass questions as a dict. However, this is not directly possible in questionary. For example:
Some command line options can be repeated (thus the question would need to be asked twice), e.g. --option VALUE1 --option VALUE2. Click passes these as a list.
Some command line options take more than one value, e.g. --option VALUE1 VALUE2
Some options should only be asked about if the user passes a previous option.
All of these cases could be handled using questionary and a bit of python to handle the logic but I wanted to do this with a dict of questions.
Describe the solution
I've created my own extension to prompt() I've called superprompt that implements these features. Specifically, it adds the following:
An if option that will ask a nested set of questions only if the answer to the current question matches a specific value. I find this easier when you have a lot of nested questions than using when.
A multiple option that can ask the same question multiple times (either an exact number of up to a certain number of times) and returns the answer as a list of values.
A list type which asks a set of nested questions and returns the answer as a list of the answers to the nested questions.
A dict type which asks a set of nested questions and returns the answer as a dict of the nested questions.
You can check out the README to see examples of these features.
I welcome any feedback on this and if there's interest in merging these into questionary, I'm happy to work on a PR.
Alternatives considered
Use python code to handle the logic.
The text was updated successfully, but these errors were encountered:
In looking at the source code for a possible implementation for #207, I see there's already a legacy list type defined as an alias for select so one change that would be needed if there's interest in merging these enhancements would be a name for what I've defined as list and dict types (which are different than defined by questionary).
Describe the problem
First, thanks for creating/maintaining questionary! This is a super useful package.
I'm working on using questionary to create an interactive "wizard" for configuring a fairly complex click CLI app (osxphotos]. I'd like the output of the questions to map directly to the input needed to configure the app. I'd really like to do this using the
prompt()
function to pass questions as a dict. However, this is not directly possible in questionary. For example:--option VALUE1 --option VALUE2
. Click passes these as a list.--option VALUE1 VALUE2
All of these cases could be handled using questionary and a bit of python to handle the logic but I wanted to do this with a
dict
of questions.Describe the solution
I've created my own extension to
prompt()
I've called superprompt that implements these features. Specifically, it adds the following:if
option that will ask a nested set of questions only if the answer to the current question matches a specific value. I find this easier when you have a lot of nested questions than usingwhen
.multiple
option that can ask the same question multiple times (either an exact number of up to a certain number of times) and returns the answer as a list of values.list
type which asks a set of nested questions and returns the answer as a list of the answers to the nested questions.dict
type which asks a set of nested questions and returns the answer as a dict of the nested questions.You can check out the README to see examples of these features.
I welcome any feedback on this and if there's interest in merging these into questionary, I'm happy to work on a PR.
Alternatives considered
Use python code to handle the logic.
The text was updated successfully, but these errors were encountered: