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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d56d68e546506c79e536586c673817efb2c2d38ae3f1a5c35aaca17ea9d4ec7f |
|
MD5 | 026f292a1c08724732ff8ef59f39d786 |
|
BLAKE2b-256 | b479535839d285c84d437e083ee0ea7e25647b286626c79501be8760809f4c80 |
Close
Hashes for better_rich_prompts-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d10fbbe72b3a181b8ad8763f7d032110592714398cee40ac4d2b88f73a4974d |
|
MD5 | b331da651bc6089ffc4225e65b3c4ee1 |
|
BLAKE2b-256 | a76d5204ec0555f509b5ad456b999b3757874ffc481397044d97453e6e53ff50 |