Decorate your command-line interface and simplify complex user input with an allowlist or blocklist.
Project description
monoprompt
Decorate your command-line interface and simplify complex user input with an allowlist or blocklist.
Install
pip install monoprompt
Usage
1. Import
from monoprompt.monoprompt import ask, request, message, decorator, catalog, keys
2. Ask an input from the user.
# basic usage
ask("What is your name? ")
# removes extra characters
ask("What is your age? ", chars="3")
# allows empty input
ask("Where do you live? ", once=True)
3. Request input and compare to allowed values.
# basic usage
request("Choose a number? ", ("1", "2", "0"))
# allows only to choose between Apple, Banana, and Cherry, and never Durian
request("Select? ", ("Apple", "Banana", "Cherry"), blocklist=("Durian"))
# allows empty input
request("Select? ", ("Apple", "Banana", "Cherry", ""), blocklist=("Durian"))
4. Decorate line with any characters.
# fills the whole console line with the specified character
decorate("#")
# limits only to 50 characters in length
decorate("#", chars=50)
# fills the whole console line with the specified word, up to the max limit
decorate("hello")
# fills the whole console line with the specified word, up to a hundred characters
decorate("hello", 100)
5. Print a message to the console.
# basic usage
message(string)
# centers message in console
message(string, centered=True)
# centers message in a 50-character length
message(string, chars=50, centered=True)
# padds a string to the leading and trailing ends of the message
message(string, padding="#", centered=True)
# fills the leading and trailing white spaces with the specified character
message(string, chars=0, fill="-", centered=True)
6. Print an ordered list.
# basic usage
catalog(("Apple", "Banana", "Cherries"))
# or
selection = ("Apple", "Banana", "Cherries")
catalog(selection)
7. Get indices of a list.
# basic usage
indices = keys(("Apple", "Banana", "Cherries"))
# extend list
indices = keys(("Apple", "Banana", "Cherries"), extend=["x"])
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
monoprompt-1.0.1.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file monoprompt-1.0.1.tar.gz
.
File metadata
- Download URL: monoprompt-1.0.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ee05e95700e311687c49142c7c236f5d58dfb75128d2023b7737b350f76f9ec |
|
MD5 | 44e69720c1c13cdddcbfe9df3dcd5367 |
|
BLAKE2b-256 | e5e4867890fb56bfeeeb2b90be273d2d2644bec985946bd70aaea23864abc97e |
File details
Details for the file monoprompt-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: monoprompt-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 048ac56a9483092478fccc249a77ea804f620d350bf7e0f1b954637f270b58e8 |
|
MD5 | c3c404d76846417f62efcdccb46e3161 |
|
BLAKE2b-256 | 77231984ee67c7a748b210ae50a9683e64b7e288393a935ea1d931c0365575e8 |