A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/CITGuru/PyInquirer below:

CITGuru/PyInquirer: A Python module for common interactive command line user interfaces

Update: We are looking for a successor/maintainance. Here: <#159> Github is starting to invite developers in from the GitHub Sponsors waitlist!

Your recommendations matter, so be sure to nominate me and other contributors of this project you'd like to see on GitHub Sponsors next by using the form in this link: http://github.co/2IHdeOw

PyInquirer is a collection of common interactive command line user interfaces.

PyInquirer 1.0.3 Bugfix Update

PyInquirer 1.0.3 <https://github.com/CITGuru/PyInquirer/releases/tag/1.0.3>

  1. Documentation
    1. Installation
    2. Examples
    3. Quickstart
    4. Question Types
    5. Question Properties
    6. User Interfaces and Styles
  2. Windows Platform
  3. Support
  4. Contribution
  5. Acknowledgments
  6. License

PyInquirer strives to be an easily embeddable and beautiful command line interface for Python. PyInquirer wants to make it easy for existing Inquirer.js users to write immersive command line applications in Python. We are convinced that its feature-set is the most complete for building immersive CLI applications. We also hope that PyInquirer proves itself useful to Python users.

PyInquirer should ease the process of - providing error feedback - asking questions - parsing input - validating answers - managing *hierarchical prompts

Note: PyInquirer provides the user interface and the inquiry session flow. >

Like most Python packages PyInquirer is available on PyPi. Simply use pip to install the PyInquirer package

In case you encounter any prompt_toolkit error, that means you've the wrong prompt_toolkit version.

You can correct that by doing

pip install prompt_toolkit==1.0.14

or download the wheel file from here:

https://pypi.org/project/prompt_toolkit/1.0.14/#files

Like Inquirer.js, using inquirer is structured into two simple steps:

from __future__ import print_function, unicode_literals
from PyInquirer import prompt, print_json

questions = [
    {
        'type': 'input',
        'name': 'first_name',
        'message': 'What\'s your first name',
    }
]

answers = prompt(questions)
print_json(answers)  # use the answers as input for your app

A good starting point from here is probably the examples section.

Most of the examples intend to demonstrate a single question type or feature:

If you want to launch examples with the code from repository instead of installing a package you need to execute pip install -e . within project directory.

questions is a list of questions. Each question has a type.

Take type, name, message, choices[, default, filter] properties. (Note that default must be the choice index in the array or a choice value)

s ---

Raw List - {type: 'rawlist'}

Take type, name, message, choices[, default, filter] properties. (Note that default must the choice index in the array)

Raw list prompt

Expand - {type: 'expand'}

Take type, name, message, choices[, default] properties. (Note that default must be the choice index in the array. If default key not provided, then help will be used as default choice)

Note that the choices object will take an extra parameter called key for the expand prompt. This parameter must be a single (lowercased) character. The h option is added by the prompt and shouldn't be defined by the user.

See examples/expand.py for a running example.

Checkbox - {type: 'checkbox'}

Take type, name, message, choices[, filter, validate] properties.

Choices marked as {'checked': True} will be checked by default.

Choices whose property disabled is truthy will be unselectable. If disabled is a string, then the string will be outputted next to the disabled choice, otherwise it'll default to "Disabled". The disabled property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string.

The pointer_index kwarg can be used to specify initial pointer position.

Checkbox prompt

Confirm - {type: 'confirm'}

Take type, name, message[, default] properties. default is expected to be a boolean if used.

Confirm prompt

Take type, name, message[, default, filter, validate] properties.

Input prompt

Password - {type: 'password'}

Take type, name, message[, default, filter, validate] properties.

Password prompt

Editor - {type: 'editor'}

Take type, name, message[, default, filter, validate, eargs] properties

Opens an empty or edits the default text in the defined editor. If an editor is given (should be the full path to the executable but the regular operating system search path is used for finding the executable) it overrides the detected editor. Optionally, some environment variables can be used. If the editor is closed without changes, None is returned. In case a file is edited directly the return value is always None and save and ext are ignored.

Takes:

Launches an instance of the users preferred editor on a temporary file. Once the user exits their editor, the contents of the temporary file are read in as the result. The editor to use is determined by reading the :math:``VISUAL or ``EDITOR environment variables. If neither of those are present, notepad (on Windows) or vim (Linux or Mac) is used.

A question is a dictionary containing question related values:

User Interfaces and Styles

TODO

``PyInquirer`` is build on prompt_toolkit which is cross platform, and everything that you build on top should run fine on both Unix and Windows systems. On Windows, it uses a different event loop (WaitForMultipleObjects instead of select), and another input and output system. (Win32 APIs instead of pseudo-terminals and VT100.)

It's worth noting that the implementation is a "best effort of what is possible". Both Unix and Windows terminals have their limitations. But in general, the Unix experience will still be a little better.

For Windows, it's recommended to use either cmder or conemu.

Most of the questions are probably related to using a question type or feature. Please lookup and study the appropriate examples.

Issue on Github TODO link

For many issues like for example common Python programming issues stackoverflow might be a good place to search for an answer. TODO link

$ git clone git@github.com:CITGuru/PyInquirer.git
$ cd PyInquirer
$ python -m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip
$ pip install -r requirements.txt
$ pip install -r requirements_dev.txt

With an environment ready you can add new feature and check everything works just fine

That's it, now you can fork a project and submit PR with your change!

Credits

This project exists thanks to all the people who contribute!

Thank you to all our backers! Become a backer.

Support us by becoming a sponsor. Your logo will show up here with a link to your website. Become a sponsor.

Copyright (c) 2018 Oyetoke Toby (twitter: @oyetokeT)

Licensed under the MIT license.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4