interrogatio


Nameinterrogatio JSON
Version 2.4.0 PyPI version JSON
download
home_pagehttps://github.com/ffaraone/interrogatio
SummaryPrompting library for terminals.
upload_time2024-12-14 09:05:30
maintainerNone
docs_urlNone
authorFrancesco Faraone
requires_python<4,>=3.8
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # interrogatio

![Python versions](https://img.shields.io/pypi/pyversions/interrogatio.svg) [![PyPi Status](https://img.shields.io/pypi/v/interrogatio.svg)](https://pypi.org/project/interrogatio/) ![Read the Docs](https://img.shields.io/readthedocs/interrogatio) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ffaraone/interrogatio/build.yml)
 [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ffaraone_interrogatio&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ffaraone_interrogatio) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ffaraone_interrogatio&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ffaraone_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](https://github.com/prompt-toolkit/python-prompt-toolkit) and inspired by [PyInquirer](https://github.com/CITGuru/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](https://interrogatio.readthedocs.io/en/latest/) 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 ``selectone`` or ``selectmany`` question types.


`interrogatio` can run into two modes: dialog and prompt.

#### Dialog mode

![Dialog mode showcase](docs/showcase/dialogus.gif)

```
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

![Prompt mode showcase](docs/showcase/interrogatio.gif)

```
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](https://opensource.org/licenses/BSD-3-Clause>).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ffaraone/interrogatio",
    "name": "interrogatio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Francesco Faraone",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/2b/63/7274ecd7fcd8e64d4b1244eb0fc4668f12e520709d7519ee97e4185003f0/interrogatio-2.4.0.tar.gz",
    "platform": null,
    "description": "#\u00a0interrogatio\n\n![Python versions](https://img.shields.io/pypi/pyversions/interrogatio.svg) [![PyPi Status](https://img.shields.io/pypi/v/interrogatio.svg)](https://pypi.org/project/interrogatio/) ![Read the Docs](https://img.shields.io/readthedocs/interrogatio) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/ffaraone/interrogatio/build.yml)\n [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ffaraone_interrogatio&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ffaraone_interrogatio) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ffaraone_interrogatio&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ffaraone_interrogatio)\n\nA python library to prompt users for inputs in a terminal application.\n\n\n## What is interrogatio\n\n`interrogatio` is a python 3.8+ library based on the [python-prompt-toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit) and inspired by [PyInquirer](https://github.com/CITGuru/PyInquirer/) that help CLI developers to ask users for inputs.\n\nQuestions can be rendered onto the terminal prompt or as curses-like dialogs.\n\n\n## Documentation\n\n[`interrogatio` documentation](https://interrogatio.readthedocs.io/en/latest/) is hosted on _Read the Docs_.\n\n\n\n## Getting started\n\n\n### Requirements\n\n`interrogatio` depends on the python-prompt-toolkit library and its dependencies.\n\n### Installation\n\n\n#### Using pip\n\n\n```\n$ pip install interrogatio\n```\n\n\n#### Extra dependencies\n\nIf you want to use the shell command with yml files you can install the yml dependency:\n\n```\n$ pip install interrogatio[yml]\n```\n\n\n### Basic usage\n\n`interrogatio` needs a list of questions to prompt the user for answers.\n\nEach question is a python dictionary with at least the following keys:\n\n* **name**: it has to be unique within the list of questions. It represents the variable name;\n* **type**: the type of question;\n* **message**: the text of the prompt.\n\nOptionally you should specify:\n    \n* a **default**: a default value;\n* a **validators**: a list of children of Validator class\n* a **values**: a list of tuples (value, label) to provide a list of choices \n    for the ``selectone`` or ``selectmany`` question types.\n\n\n`interrogatio` can run into two modes: dialog and prompt.\n\n#### Dialog mode\n\n![Dialog mode showcase](docs/showcase/dialogus.gif)\n\n```\nfrom interrogatio import dialogus\n\nquestions = [\n    {\n        'name': 'name',\n        'type': 'input',\n        'message': \"What's your name ?\",\n        'description': 'Please enter your full name. This field is required.',\n        'validators': [{'name': 'required'}],\n    },\n    {\n        'name': 'birth_date',\n        'type': 'date',\n        'message': \"What's your birth date ?\",\n        'description': 'Enter your birth date.',\n    },\n    {\n        'name': 'nationality',\n        'type': 'selectone',\n        'message': \"What's your nationality ?\",\n        'description': 'Please choose one from the list.',\n        'validators': [{'name': 'required'}],\n        'values': [\n            ('IT', 'Italian'),\n            ('ES', 'Spanish'),\n            ('US', 'American'),\n            ('UK', 'English'),\n        ],\n    },\n    {\n        'name': 'languages',\n        'type': 'selectmany',\n        'message': \"What are your favorite programming languages ?\",\n        'description': 'Please choose your favorites from the list.',\n        'values': [\n            ('py', 'Python'),\n            ('rb', 'Ruby'),\n            ('js', 'Javascript'),\n            ('go', 'Golang'),\n            ('rs', 'Rust'),\n            ('c', 'C'),\n            ('cpp', 'C++'),\n            ('java', 'Java'),\n        ],\n    },\n]\n\nintro = \"\"\"<blue>Welcome to <b><i>interrogatio 2.0</i></b>!\n\nThis is the second major release of interrogatio with nice improvements.</blue>\n\n<b>What's new</b>\n<b>----------</b>\n\n* Curses-like dialog experience had been completely rewritten.\n* New questions handlers for dates, date ranges and masked inputs.\n* Validators are now based on the <u>validators</u> library.\n\"\"\"\n\n\nanswers = dialogus(questions, 'interrogatio showcase', intro=intro, summary=True)\n```\n\n#### Prompt mode\n\n![Prompt mode showcase](docs/showcase/interrogatio.gif)\n\n```\nfrom interrogatio import interrogatio\n\nquestions = [\n    {\n        'name': 'name',\n        'type': 'input',\n        'message': \"What's your name ?\",\n        'description': 'Please enter your full name. This field is required.',\n        'validators': [{'name': 'required'}],\n    },\n    {\n        'name': 'birth_date',\n        'type': 'date',\n        'message': \"What's your birth date ?\",\n        'description': 'Enter your birth date.',\n    },\n    {\n        'name': 'nationality',\n        'type': 'selectone',\n        'message': \"What's your nationality ?\",\n        'description': 'Please choose one from the list.',\n        'validators': [{'name': 'required'}],\n        'values': [\n            ('IT', 'Italian'),\n            ('ES', 'Spanish'),\n            ('US', 'American'),\n            ('UK', 'English'),\n        ],\n    },\n    {\n        'name': 'languages',\n        'type': 'selectmany',\n        'message': \"What are your favorite programming languages ?\",\n        'description': 'Please choose your favorites from the list.',\n        'values': [\n            ('py', 'Python'),\n            ('rb', 'Ruby'),\n            ('js', 'Javascript'),\n            ('go', 'Golang'),\n            ('rs', 'Rust'),\n            ('c', 'C'),\n            ('cpp', 'C++'),\n            ('java', 'Java'),\n        ],\n    },\n]\n\n\nanswers = interrogatio(questions)\n```\n\n### Contributing\n\nIf you want to contribute to the project, you can submit bugs, feature requests or fork the github repository and submit your pull request.\n\n\n### License\n\n`interrogatio` is released under the [BSD 3-Clause \"New\" or \"Revised\" License](https://opensource.org/licenses/BSD-3-Clause>).\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Prompting library for terminals.",
    "version": "2.4.0",
    "project_urls": {
        "Documentation": "https://interrogatio.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/ffaraone/interrogatio",
        "Repository": "https://github.com/ffaraone/interrogatio.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc3a7374c514c7dc5e69be1c0ae4f030f96c035e4ea62885fdc9a02a5c9c33d6",
                "md5": "c79046def2cce0da2474de6d65019e9d",
                "sha256": "0c4bf4fbe837ec50b1c957248b50ba26f62a1209a37284125c011479347d21e7"
            },
            "downloads": -1,
            "filename": "interrogatio-2.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c79046def2cce0da2474de6d65019e9d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 26787,
            "upload_time": "2024-12-14T09:05:29",
            "upload_time_iso_8601": "2024-12-14T09:05:29.836412Z",
            "url": "https://files.pythonhosted.org/packages/dc/3a/7374c514c7dc5e69be1c0ae4f030f96c035e4ea62885fdc9a02a5c9c33d6/interrogatio-2.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b637274ecd7fcd8e64d4b1244eb0fc4668f12e520709d7519ee97e4185003f0",
                "md5": "46b0f3322f401b214a62cb7f5d5da071",
                "sha256": "3d95ef615a32ce15d52a94e57f420699dd3f894ead1b34e089b571a1200dba2f"
            },
            "downloads": -1,
            "filename": "interrogatio-2.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "46b0f3322f401b214a62cb7f5d5da071",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 21960,
            "upload_time": "2024-12-14T09:05:30",
            "upload_time_iso_8601": "2024-12-14T09:05:30.913175Z",
            "url": "https://files.pythonhosted.org/packages/2b/63/7274ecd7fcd8e64d4b1244eb0fc4668f12e520709d7519ee97e4185003f0/interrogatio-2.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-14 09:05:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ffaraone",
    "github_project": "interrogatio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "interrogatio"
}
        
Elapsed time: 0.73318s