enquiries


Nameenquiries JSON
Version 0.2.0 PyPI version JSON
download
home_page
SummaryAsk simple questions - get simple answers
upload_time2023-04-23 09:22:37
maintainer
docs_urlNone
authorPeter Holloway
requires_python>=3.7,<4.0
licenseMPL-2.0
keywords cli prompt input
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Enquiries
=========

``enquiries`` aims to provide a straightforward way to get decisions from your users.
It can offer multiple choice, yes/no or free text

.. code-block:: python

    import enquiries

    options = ['thing 1', 'thing 2', 'thing 3']
    choice = enquiries.choose('Choose one of these options: ', options)

    if enquiries.confirm('Do you want to write something?'):
        text = enquiries.freetext('Write something interesting: ')
        print(text)

Input for these questions is fully interactive and prevents any incorrect
responses. No more loops checking if the answer matches the question. No more
mapping the text entered to original objects. Let users choose the objects
directly.

.. image:: https://asciinema.org/a/6OyuQH9H03vSP2gf79f0KwaCO.png
   :target: https://asciinema.org/a/6OyuQH9H03vSP2gf79f0KwaCO
   :width: 80%

Multiple choice
---------------
All choices consist of letting users pick one of several items. For ``enquiries`` these
can be in any iterable.

Users can pick one or many of the options offered to them.

Single Selection
~~~~~~~~~~~~~~~~

For single choice, use the ``choose`` method with the list of choices.

.. code-block:: python

    >>> options = ['Thing 1', 'Thing 2']
    >>> response = enquiries.choose('Pick a thing', options)
    # interactive prompt
    >>> print('You chose "{}"'.format(response))
    You chose "Thing 1"
    >>>

The interactive prompt here appears as list of options you can scroll through
and select using the return key::

    Pick a thing
    > Thing 1
      Thing 2
      Thing 3

Where up/down arrow keys will scroll through the options moving the ``>``
marker. The currently selected option is also in bold typeface (if the terminal
supports it).

Multiple Selections
~~~~~~~~~~~~~~~~~~~
For cases where the user can choose multiple options, the ``multi`` keyword can
be used.

.. code-block:: python

    >>> options = ['Thing 1', 'Thing 2', 'Thing 3']
    >>> response = enquiries.choose('Pick some things', options, multi=True)
    # interactive prompt
    >>> print('You chose "{}"'.format(response))
    You chose "['Thing1', 'Thing 3']"
    >>>

The interactive prompt for multiple choice is similar to that used for single
choice but the `>` marker is replaces with ◉ and ◌ to signify chosen or not
chosen. As before, the arrow keys change the selection and the current line is
bold. The space key is used to mark an option as selected.::

    pick a thing
    ◉ Thing 1
    ◌ Thing 2
    ◌ Thing 3

Yes/No Confirmation
-------------------

Used to get a simple boolean response from users.

.. code-block:: python

    >>> if enquiries.confirm('Do you really want to do the thing')
    ...     print('Carrying on')
    ... else:
    ...     print('Exiting')
    ...
    # interactive prompt
    Carrying on
    >>>

Results in the prompt below::

    Do you really want to do the thing? [y/N]

The prompt for confirmation by default accepts ``y``/``n`` keys to choose and
return to accept the choice. Return without choosing accepts the default value
(usually ``False``). The keys used and the default can be changed as required.
By default, the user should choose y/n then hit return but ``single_key`` mode
can be used to remove the need to hit return.


Freetext
--------
``enquiries`` free text offering is offers a slightly enhanced version of the
`input <https://docs.python.org/3/library/functions.html>`_ builtin function. It adds multi line support as well as basic
readline like controls (``Ctrl-a``, ``Ctrl-w`` etc). The text entry area is also cleared after the text is
accepted keeping terminal history clean.

.. code-block:: python

    >>> text = enquiries.freetext('Write some stuff')
    >>> print(text)
    This is the text you entered
    on many lines
    >>>

New lines in text can be entered using ``Alt``-``Return``.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "enquiries",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "cli,prompt,input",
    "author": "Peter Holloway",
    "author_email": "holloway.p.r@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a7/ff/a31e613be5d4ece22bf6f469b116f53e5c56a564540f8b32945ac30f4ba2/enquiries-0.2.0.tar.gz",
    "platform": null,
    "description": "Enquiries\n=========\n\n``enquiries`` aims to provide a straightforward way to get decisions from your users.\nIt can offer multiple choice, yes/no or free text\n\n.. code-block:: python\n\n    import enquiries\n\n    options = ['thing 1', 'thing 2', 'thing 3']\n    choice = enquiries.choose('Choose one of these options: ', options)\n\n    if enquiries.confirm('Do you want to write something?'):\n        text = enquiries.freetext('Write something interesting: ')\n        print(text)\n\nInput for these questions is fully interactive and prevents any incorrect\nresponses. No more loops checking if the answer matches the question. No more\nmapping the text entered to original objects. Let users choose the objects\ndirectly.\n\n.. image:: https://asciinema.org/a/6OyuQH9H03vSP2gf79f0KwaCO.png\n   :target: https://asciinema.org/a/6OyuQH9H03vSP2gf79f0KwaCO\n   :width: 80%\n\nMultiple choice\n---------------\nAll choices consist of letting users pick one of several items. For ``enquiries`` these\ncan be in any iterable.\n\nUsers can pick one or many of the options offered to them.\n\nSingle Selection\n~~~~~~~~~~~~~~~~\n\nFor single choice, use the ``choose`` method with the list of choices.\n\n.. code-block:: python\n\n    >>> options = ['Thing 1', 'Thing 2']\n    >>> response = enquiries.choose('Pick a thing', options)\n    # interactive prompt\n    >>> print('You chose \"{}\"'.format(response))\n    You chose \"Thing 1\"\n    >>>\n\nThe interactive prompt here appears as list of options you can scroll through\nand select using the return key::\n\n    Pick a thing\n    > Thing 1\n      Thing 2\n      Thing 3\n\nWhere up/down arrow keys will scroll through the options moving the ``>``\nmarker. The currently selected option is also in bold typeface (if the terminal\nsupports it).\n\nMultiple Selections\n~~~~~~~~~~~~~~~~~~~\nFor cases where the user can choose multiple options, the ``multi`` keyword can\nbe used.\n\n.. code-block:: python\n\n    >>> options = ['Thing 1', 'Thing 2', 'Thing 3']\n    >>> response = enquiries.choose('Pick some things', options, multi=True)\n    # interactive prompt\n    >>> print('You chose \"{}\"'.format(response))\n    You chose \"['Thing1', 'Thing 3']\"\n    >>>\n\nThe interactive prompt for multiple choice is similar to that used for single\nchoice but the `>` marker is replaces with \u25c9 and \u25cc to signify chosen or not\nchosen. As before, the arrow keys change the selection and the current line is\nbold. The space key is used to mark an option as selected.::\n\n    pick a thing\n    \u25c9 Thing 1\n    \u25cc Thing 2\n    \u25cc Thing 3\n\nYes/No Confirmation\n-------------------\n\nUsed to get a simple boolean response from users.\n\n.. code-block:: python\n\n    >>> if enquiries.confirm('Do you really want to do the thing')\n    ...     print('Carrying on')\n    ... else:\n    ...     print('Exiting')\n    ...\n    # interactive prompt\n    Carrying on\n    >>>\n\nResults in the prompt below::\n\n    Do you really want to do the thing? [y/N]\n\nThe prompt for confirmation by default accepts ``y``/``n`` keys to choose and\nreturn to accept the choice. Return without choosing accepts the default value\n(usually ``False``). The keys used and the default can be changed as required.\nBy default, the user should choose y/n then hit return but ``single_key`` mode\ncan be used to remove the need to hit return.\n\n\nFreetext\n--------\n``enquiries`` free text offering is offers a slightly enhanced version of the\n`input <https://docs.python.org/3/library/functions.html>`_ builtin function. It adds multi line support as well as basic\nreadline like controls (``Ctrl-a``, ``Ctrl-w`` etc). The text entry area is also cleared after the text is\naccepted keeping terminal history clean.\n\n.. code-block:: python\n\n    >>> text = enquiries.freetext('Write some stuff')\n    >>> print(text)\n    This is the text you entered\n    on many lines\n    >>>\n\nNew lines in text can be entered using ``Alt``-``Return``.\n",
    "bugtrack_url": null,
    "license": "MPL-2.0",
    "summary": "Ask simple questions - get simple answers",
    "version": "0.2.0",
    "split_keywords": [
        "cli",
        "prompt",
        "input"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2e1fe0ab93ace93d7f11b34e65f787e110827786a6cdf93d10dfebc997d8a65c",
                "md5": "dc2665694249f47e8038a660275a6d2a",
                "sha256": "b8d43455256077d167945cb819e5d897bc0465074e46d54fe683e71cd6eb6bb1"
            },
            "downloads": -1,
            "filename": "enquiries-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dc2665694249f47e8038a660275a6d2a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 16059,
            "upload_time": "2023-04-23T09:22:34",
            "upload_time_iso_8601": "2023-04-23T09:22:34.870686Z",
            "url": "https://files.pythonhosted.org/packages/2e/1f/e0ab93ace93d7f11b34e65f787e110827786a6cdf93d10dfebc997d8a65c/enquiries-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7ffa31e613be5d4ece22bf6f469b116f53e5c56a564540f8b32945ac30f4ba2",
                "md5": "68defe346651beafcdd42b460a3a6312",
                "sha256": "f151d67d24371586d8f9196423c7af8849987a3e406ff1750e99cb3256fd9521"
            },
            "downloads": -1,
            "filename": "enquiries-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "68defe346651beafcdd42b460a3a6312",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 15897,
            "upload_time": "2023-04-23T09:22:37",
            "upload_time_iso_8601": "2023-04-23T09:22:37.147534Z",
            "url": "https://files.pythonhosted.org/packages/a7/ff/a31e613be5d4ece22bf6f469b116f53e5c56a564540f8b32945ac30f4ba2/enquiries-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-23 09:22:37",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "enquiries"
}
        
Elapsed time: 0.06736s