Improved prompts for rich.
Project description
better-rich-prompts is a Python extension library for Rich.
This Library makes it easy to use lists and dictionaries as choices for prompt.ask
.
Compatibility
This library should work
Installing
python -m pip install better-rich-prompts
Using List Prompt
Example 1 - Using list of dictionaries
from better_rich_prompts.prompt import ListPrompt
choices = [
{"name": "english", "language_code": "en"},
{"name": "spanish", "language_code": "es"},
{"name":"french","language_code":"fr"},
]
ListPrompt.ask("Select a language", choices, choice_key="name")
Example 2 - Using list of strings
from better_rich_prompts.prompt import ListPrompt
choices = ["en", "es", "fr"]
ListPrompt.ask("Select a language", choices,default="en")
Example 3 - Using list of custom objects
from better_rich_prompts.prompt import ListPrompt
class Language:
def __init__(self, name, code):
self.name = name
self.code = code
choices = [
Language("english", "en"),
Language("spanish", "es"),
Language("french", "fr"),
]
ListPrompt.ask(
"Select a language", choices, default="en", choice_key=lambda c: c.code
)
Using Dict Prompt
from better_rich_prompts.prompt import DictPrompt
choices = {"en":"english","es":"spanish","fr":"french"}
DictPrompt.ask("Select a language", choices)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for better_rich_prompts-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75f8b059a3dac3344c1b322726fd9db296a4dcdb8c84be1fb0dc558074023ead |
|
MD5 | 1f54abfedb34fe71ef7a33cf7b3be7da |
|
BLAKE2b-256 | 7f559180cbadba2ba0514cd14cc1c922bf5a796a18d54c5d413c25d77bdd8822 |
Close
Hashes for better_rich_prompts-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ef747a8e392739608d50b9f0be0729ec8994c06dfe840362f114bc9292579d0 |
|
MD5 | b5c4780f44f7160d8e48e37d8e6e0ed9 |
|
BLAKE2b-256 | 870d8cf799a7ac829d73abf5c84e9df0d8abd84552c60253dd5f55d1d0ebfd7b |