Skip to main content

PyInquirer-inspired prompt library

Project description

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

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

enquire-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

enquire-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file enquire-0.1.0.tar.gz.

File metadata

  • Download URL: enquire-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for enquire-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c5d128a71dcafc688049a67cb5bbe7653975d9389e2e037d7a8f2905c015ab12
MD5 ea1fd03fd6c6ef47c741b545fca2b85b
BLAKE2b-256 280220abedb4bda79172b657b2fc075c33cc9ae9ea5a7385136ea64a578a4477

See more details on using hashes here.

File details

Details for the file enquire-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: enquire-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for enquire-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0112fc8939a55c2a600037773c757a26c890b3d97be29ca559b24abfd6936ed
MD5 033203c552cfb7ff21a6f7a7c6c24419
BLAKE2b-256 3f406743f709cc421059b661c087c10c17a61b0f2395b9d8cb287807092e9175

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