Skip to main content

Prompt toolkit for console interaction

Project description

NonePrompt

Prompt toolkit for console interaction.

Typing is fully supported. Async is also supported!

Installation

pip install noneprompt

Prompt Usage

Input

from noneprompt import InputPrompt

InputPrompt("What is your name?", validator=lambda string: True).prompt()
await InputPrompt("What is your name?", validator=lambda string: True).prompt_async()

Confirm

from noneprompt import ConfirmPrompt

ConfirmPrompt("Are you sure?", default_choice=False).prompt()
await ConfirmPrompt("Are you sure?", default_choice=False).prompt_async()

List

from noneprompt import ListPrompt, Choice

ListPrompt("What is your favorite color?", choices=[Choice("Red"), Choice("Blue")]).prompt()
await ListPrompt("What is your favorite color?", choices=[Choice("Red"), Choice("Blue")]).prompt_async()

Checkbox

from noneprompt import CheckboxPrompt, Choice

CheckboxPrompt("Choose your favorite colors", choices=[Choice("Red"), Choice("Blue")]).prompt()
await CheckboxPrompt("Choose your favorite colors", choices=[Choice("Red"), Choice("Blue")]).prompt_async()

Choice Data

You can add data to choices. Result type can be inferred from the data type.

from noneprompt import ListPrompt, Choice

result: Choice[str] = ListPrompt(
    "What is your favorite color?",
    choices=[
        Choice("Red", data="#FF0000"),
        Choice("Blue", data="#0000FF"),
    ],
).prompt()
print(result.data)

Defaults and Cancellation

from noneprompt import InputPrompt

result = InputPrompt("Press Ctrl-C to cancel.").prompt(default="Cancelled")
assert result == "Cancelled"
from noneprompt import InputPrompt, CancelledError

try:
    InputPrompt("Press Ctrl-C to cancel.").prompt()
except CancelledError:
    # Do something
    pass

Style Guide

See the docstring of prompt classes for more information.

from noneprompt import InputPrompt
from prompt_toolkit.styles import Style

InputPrompt("What is your name?").prompt(style=Style([("input": "#ffffff"), ("answer": "bold")]))

Disable ansi colors:

from noneprompt import InputPrompt

InputPrompt("What is your name?").prompt(no_ansi=True)

Try from command line

noneprompt -h

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

noneprompt-0.1.11.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noneprompt-0.1.11-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file noneprompt-0.1.11.tar.gz.

File metadata

  • Download URL: noneprompt-0.1.11.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for noneprompt-0.1.11.tar.gz
Algorithm Hash digest
SHA256 68226918f2a1543aa380caada5c380ae5ca38f57292278c5bfd3b7289f1ac6db
MD5 1c61efdb8452b62c9e7258beb9f45cfe
BLAKE2b-256 f4bedf8efafed7989d60c0d0d87559e65cdc40a6321186e13955cb85f289cd09

See more details on using hashes here.

File details

Details for the file noneprompt-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: noneprompt-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for noneprompt-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e3d83e7cf57f645a35c6b8eaf918baefe077c41b761bb6326e8e6adb4f73150e
MD5 5876eee049d7457cda50b664d586d61e
BLAKE2b-256 7cac0c16167b09d35851235e2703cca1b860a150122f1d698bc2367309bd5d9f

See more details on using hashes here.

Supported by

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