# interrogatio
A python library to prompt users for inputs in a terminal application.
What is interrogatio
interrogatio is a python 3.8+ library based on the python-prompt-toolkit and inspired by PyInquirer that help CLI developers to ask users for inputs.
Questions can be rendered onto the terminal prompt or as curses-like dialogs.
Documentation
interrogatio documentation is hosted on Read the Docs.
Getting started
Requirements
interrogatio depends on the python-prompt-toolkit library and its dependencies.
Installation
Using pip
$ pip install interrogatio
Extra dependencies
If you want to use the shell command with yml files you can install the yml dependency:
$ pip install interrogatio[yml]
Basic usage
interrogatio needs a list of questions to prompt the user for answers.
Each question is a python dictionary with at least the following keys:
- name: it has to be unique within the list of questions. It represents the variable name;
- type: the type of question;
- message: the text of the prompt.
Optionally you should specify:
- a default: a default value;
- a validators: a list of children of Validator class
- a values: a list of tuples (value, label) to provide a list of choices
for the
selectoneorselectmanyquestion types.
interrogatio can run into two modes: dialog and prompt.
Dialog mode
from interrogatio import dialogus
questions = [
{
'name': 'name',
'type': 'input',
'message': "What's your name ?",
'description': 'Please enter your full name. This field is required.',
'validators': [{'name': 'required'}],
},
{
'name': 'birth_date',
'type': 'date',
'message': "What's your birth date ?",
'description': 'Enter your birth date.',
},
{
'name': 'nationality',
'type': 'selectone',
'message': "What's your nationality ?",
'description': 'Please choose one from the list.',
'validators': [{'name': 'required'}],
'values': [
('IT', 'Italian'),
('ES', 'Spanish'),
('US', 'American'),
('UK', 'English'),
],
},
{
'name': 'languages',
'type': 'selectmany',
'message': "What are your favorite programming languages ?",
'description': 'Please choose your favorites from the list.',
'values': [
('py', 'Python'),
('rb', 'Ruby'),
('js', 'Javascript'),
('go', 'Golang'),
('rs', 'Rust'),
('c', 'C'),
('cpp', 'C++'),
('java', 'Java'),
],
},
]
intro = """<blue>Welcome to <b><i>interrogatio 2.0</i></b>!
This is the second major release of interrogatio with nice improvements.</blue>
<b>What's new</b>
<b>----------</b>
* Curses-like dialog experience had been completely rewritten.
* New questions handlers for dates, date ranges and masked inputs.
* Validators are now based on the <u>validators</u> library.
"""
answers = dialogus(questions, 'interrogatio showcase', intro=intro, summary=True)
Prompt mode
from interrogatio import interrogatio
questions = [
{
'name': 'name',
'type': 'input',
'message': "What's your name ?",
'description': 'Please enter your full name. This field is required.',
'validators': [{'name': 'required'}],
},
{
'name': 'birth_date',
'type': 'date',
'message': "What's your birth date ?",
'description': 'Enter your birth date.',
},
{
'name': 'nationality',
'type': 'selectone',
'message': "What's your nationality ?",
'description': 'Please choose one from the list.',
'validators': [{'name': 'required'}],
'values': [
('IT', 'Italian'),
('ES', 'Spanish'),
('US', 'American'),
('UK', 'English'),
],
},
{
'name': 'languages',
'type': 'selectmany',
'message': "What are your favorite programming languages ?",
'description': 'Please choose your favorites from the list.',
'values': [
('py', 'Python'),
('rb', 'Ruby'),
('js', 'Javascript'),
('go', 'Golang'),
('rs', 'Rust'),
('c', 'C'),
('cpp', 'C++'),
('java', 'Java'),
],
},
]
answers = interrogatio(questions)
Contributing
If you want to contribute to the project, you can submit bugs, feature requests or fork the github repository and submit your pull request.
License
interrogatio is released under the BSD 3-Clause "New" or "Revised" License.
Metadata
Release files for interrogatio 2.4.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 | Provenance | |
|---|---|---|---|---|
| interrogatio-2.4.0.tar.gz | 22.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| interrogatio-2.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.7 kB
Release files / interrogatio-2.4.0.tar.gz
| Download URL | interrogatio-2.4.0.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d95ef615a32ce15d52a94e57f420699dd3f894ead1b34e089b571a1200dba2f
|
|
BLAKE2b-256 checksum How to use checksums |
2b637274ecd7fcd8e64d4b1244eb0fc4668f12e520709d7519ee97e4185003f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure
|
Release files / interrogatio-2.4.0-py3-none-any.whl
| Download URL | interrogatio-2.4.0-py3-none-any.whl |
|---|---|
| Size | 26.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c4bf4fbe837ec50b1c957248b50ba26f62a1209a37284125c011479347d21e7
|
|
BLAKE2b-256 checksum How to use checksums |
dc3a7374c514c7dc5e69be1c0ae4f030f96c035e4ea62885fdc9a02a5c9c33d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure
|
Security for interrogatio 2.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.