Choice - dropdown list instead of all comma separated values in one line
See original GitHub issueHi All,
This is more a question. I’m using a choice prompt with a list of values which are quite long (each value is more than 30 characters in length).
esclation_policy = click.prompt('Please choose the escalation policy',
type=click.Choice(esclation_policy_list),
default='Default Team')
I would like to print each value on a separate line but by default they are printed comma separated until line wraps - which is very unreadable.
Is there any way to achieve the below ?
Please choose the escalation policy:
value1
value2
value3
...
valueN
instead of:
Please choose the escalation policy(value1, value2, value3, ..., valueN)
PS: I couldn’t find in documentation support for this.
Thanks & Regards, Constantin
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
excel dropdown list - commas used to separate items in Source
Hey guys, I am trying to create a dropdown list in excel using the Data Validation button. ... Do the commas show in...
Read more >Better way to load dropdown list from comma separated string
I have a string of comma separated values.
Read more >Create a dropdown list from comma-separated items - YouTube
00:00 Intro00:08 Why use list of items00:18 What it all looks like00:30 Creating a list from items01:43 Duplicating the dropdown02:01 A ...
Read more >Comma Delimited Text makes their own Dropdowns in ...
In this video we allow the user to write their own dropdowns using comma delimited single line text fields and then they can...
Read more >The Ultimate Guide to Dropdown Lists in Excel
Use Comma Separated List of Values for List Items. The first method is the most basic where all items are entered in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This might become possible with #938.
You could monkey patch
_build_prompt
to get the behavior you want.You would also need to subclass or patch Choice to change the behavior of the invalid choice error message.
I believe this is the part you would need to override. https://github.com/pallets/click/blob/2c622eed402c64e1645db3904c2410f6c05fbf19/click/types.py#L129
Feel free to continue the discussion, however I am going to close this issue because it isn’t a bug/ isn’t related to improving Click.