enquire
Goal
Enquire is a pet project with no ambitions. However, a bit of history might shed some light on the project goals.
It was a cold April morning and the dew on the grass was frozen like a tiny piece of glass.
Eric Cartman
I needed a modern cli prompt library to add some interactivity to my working projects. PyInquirer turned out to be the most easy-to-use and convenient among all the libs I could find.
Unfortunately, the latest version published on pypi had at least one critical bug: it completely ignored
the default value for list prompts. The GitHub version does not have that bug, however, it seems to be
abandoned for quite some years.
Since I only needed the basic, the radio button, and the checkbox types, these were implemented first.
Installation
pip install enquire
Basic usage
from enquire.prompt import prompt
from enquire.question import Text
if __name__ == "__main__":
questions = [
Text("name", "What's your name?", default="Christian")
]
answers = prompt(questions)
print(answers)
Question types
Text
Text is the most basic prompt type. It asks you a question and waits for you to type an answer. If there is a default value it will be pre-typed for you.
Params
name - a unique key in the answers dict
message - a message to show to user
validate - an optional function accepting the current answers dict and the current answer being typed by a user.
The function must return True if the answer is valid. There are built-in validation functions in
the library like is_int, is_number etc.
Checkbox
Checkbox prompt generates a list of checkboxes and asks a user to pick 0..n options. The resulting answer will be an array of picked values.
Radio
Radio prompt presents a list of options and asks a user to pick exactly one of them.
Boolean
Boolean is a special prompt which is pre-configured Radio with only two options - positive and negative. You can choose how these are named (the defaults are yes and no)
This documentation is a work in progress, check out the examples folder to get some usage tips
To run an example clone the repo, install the dependencies, and run
PYTHONPATH="." python examples/text.py
Metadata
Release files for enquire 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| enquire-0.1.0.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| enquire-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.8 kB
Release files / enquire-0.1.0.tar.gz
| Download URL | enquire-0.1.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5d128a71dcafc688049a67cb5bbe7653975d9389e2e037d7a8f2905c015ab12
|
|
BLAKE2b-256 checksum How to use checksums |
280220abedb4bda79172b657b2fc075c33cc9ae9ea5a7385136ea64a578a4477
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / enquire-0.1.0-py3-none-any.whl
| Download URL | enquire-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0112fc8939a55c2a600037773c757a26c890b3d97be29ca559b24abfd6936ed
|
|
BLAKE2b-256 checksum How to use checksums |
3f406743f709cc421059b661c087c10c17a61b0f2395b9d8cb287807092e9175
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|