Skip to main content

Improved prompts for rich.

Project description

Supported Python Versions PyPI version

Downloads

English readme

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")

ListPrompt Example

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")

ListPrompt Example

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
)

ListPrompt Example

Using Dict Prompt

from better_rich_prompts.prompt import DictPrompt

choices = {"en":"english","es":"spanish","fr":"french"}
DictPrompt.ask("Select a language", choices)

ListPrompt Example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

better_rich_prompts-1.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

better_rich_prompts-1.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file better_rich_prompts-1.0.2.tar.gz.

File metadata

  • Download URL: better_rich_prompts-1.0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for better_rich_prompts-1.0.2.tar.gz
Algorithm Hash digest
SHA256 75f8b059a3dac3344c1b322726fd9db296a4dcdb8c84be1fb0dc558074023ead
MD5 1f54abfedb34fe71ef7a33cf7b3be7da
BLAKE2b-256 7f559180cbadba2ba0514cd14cc1c922bf5a796a18d54c5d413c25d77bdd8822

See more details on using hashes here.

File details

Details for the file better_rich_prompts-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for better_rich_prompts-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ef747a8e392739608d50b9f0be0729ec8994c06dfe840362f114bc9292579d0
MD5 b5c4780f44f7160d8e48e37d8e6e0ed9
BLAKE2b-256 870d8cf799a7ac829d73abf5c84e9df0d8abd84552c60253dd5f55d1d0ebfd7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page