enquire


Nameenquire JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryPyInquirer-inspired prompt library
upload_time2023-08-27 17:42:39
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT
keywords click pyinquirer prompt-toolkit cli command-line commandline command-line-interface python-inquiry inquirer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## 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](https://github.com/CITGuru/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

```commandline
pip install enquire
```

### Basic usage

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

```commandline
PYTHONPATH="." python examples/text.py
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "enquire",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "click,PyInquirer,prompt-toolkit,cli,command-line,commandline,command-line-interface,python-inquiry,inquirer",
    "author": "",
    "author_email": "Pavel Vorobyev <viert.ru@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/28/02/20abedb4bda79172b657b2fc075c33cc9ae9ea5a7385136ea64a578a4477/enquire-0.1.0.tar.gz",
    "platform": null,
    "description": "## enquire\n\n### Goal\n\n**Enquire** is a pet project with no ambitions. However, a bit of history might shed some light on the project goals.\n\n> _It was a cold April morning and the dew on the grass was frozen like a tiny piece of glass._\n> \n> _Eric Cartman_\n\nI needed a modern cli prompt library to add some interactivity to my working projects.\n[PyInquirer](https://github.com/CITGuru/PyInquirer) turned out to be the most easy-to-use \nand convenient among all the libs I could find.\n\nUnfortunately, the latest version published on pypi had at least one critical bug: it completely ignored\nthe default value for `list` prompts. The GitHub version does not have that bug, however, it seems to be\nabandoned for quite some years.\n\nSince I only needed the basic, the radio button, and the checkbox types, these were implemented first.\n\n\n### Installation\n\n```commandline\npip install enquire\n```\n\n### Basic usage\n\n```python\nfrom enquire.prompt import prompt\nfrom enquire.question import Text\n\nif __name__ == \"__main__\":\n    questions = [\n        Text(\"name\", \"What's your name?\", default=\"Christian\")\n    ]\n\n    answers = prompt(questions)\n    print(answers)\n```\n\n\n### Question types\n\n#### Text\n\n**Text** is the most basic prompt type. It asks you a question and waits for you to type an answer.\nIf there is a default value it will be pre-typed for you.\n\n**Params**\n\n`name` - a unique key in the answers dict\n\n`message` - a message to show to user\n\n`validate` - an optional function accepting the current answers dict and the current answer being typed by a user. \nThe function must return `True` if the answer is valid. There are built-in validation functions in \nthe library like `is_int`, `is_number` etc.\n\n#### Checkbox\n\n**Checkbox** prompt generates a list of checkboxes and asks a user to pick 0..n options.\nThe resulting answer will be an array of picked values.\n\n### Radio\n\n**Radio** prompt presents a list of options and asks a user to pick exactly one of them.\n\n\n### Boolean\n\n**Boolean** is a special prompt which is pre-configured **Radio** with only two options - positive and negative.\nYou can choose how these are named (the defaults are _yes_ and _no_)\n\n---\n\n_This documentation is a work in progress, check out the examples folder to get some usage tips_\n\nTo run an example clone the repo, install the dependencies, and run\n\n```commandline\nPYTHONPATH=\".\" python examples/text.py\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PyInquirer-inspired prompt library",
    "version": "0.1.0",
    "project_urls": {
        "repository": "https://github.com/viert/enquire"
    },
    "split_keywords": [
        "click",
        "pyinquirer",
        "prompt-toolkit",
        "cli",
        "command-line",
        "commandline",
        "command-line-interface",
        "python-inquiry",
        "inquirer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f406743f709cc421059b661c087c10c17a61b0f2395b9d8cb287807092e9175",
                "md5": "033203c552cfb7ff21a6f7a7c6c24419",
                "sha256": "b0112fc8939a55c2a600037773c757a26c890b3d97be29ca559b24abfd6936ed"
            },
            "downloads": -1,
            "filename": "enquire-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "033203c552cfb7ff21a6f7a7c6c24419",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 10483,
            "upload_time": "2023-08-27T17:42:38",
            "upload_time_iso_8601": "2023-08-27T17:42:38.020406Z",
            "url": "https://files.pythonhosted.org/packages/3f/40/6743f709cc421059b661c087c10c17a61b0f2395b9d8cb287807092e9175/enquire-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "280220abedb4bda79172b657b2fc075c33cc9ae9ea5a7385136ea64a578a4477",
                "md5": "ea1fd03fd6c6ef47c741b545fca2b85b",
                "sha256": "c5d128a71dcafc688049a67cb5bbe7653975d9389e2e037d7a8f2905c015ab12"
            },
            "downloads": -1,
            "filename": "enquire-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ea1fd03fd6c6ef47c741b545fca2b85b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 8270,
            "upload_time": "2023-08-27T17:42:39",
            "upload_time_iso_8601": "2023-08-27T17:42:39.579780Z",
            "url": "https://files.pythonhosted.org/packages/28/02/20abedb4bda79172b657b2fc075c33cc9ae9ea5a7385136ea64a578a4477/enquire-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-27 17:42:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "viert",
    "github_project": "enquire",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "enquire"
}
        
Elapsed time: 0.09446s