Package: interrogatio
# interrogatioA python library to prompt users for inputs in a terminal application.What is interrogatiointerrogatiois a python 3.8+ library based on thepython-prompt-toolkitand inspired byPyInquirerthat help CLI developers to ask users for inputs.Questions can be rendered onto the terminal prompt or as curses-like dialogs.Documentationinterrogatiodocumentationis hosted onRead the Docs.Getting startedRequirementsinterrogatiodepends on the python-prompt-toolkit library and its dependencies.InstallationUsing pip$ pip install interrogatioExtra dependenciesIf you want to use the shell command with yml files you can install the yml dependency:$ pip install interrogatio[yml]Basic usageinterrogationeeds 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:adefault: a default value;avalidators: a list of children of Validator classavalues: a list of tuples (value, label) to provide a list of choices
for theselectoneorselectmanyquestion types.interrogatiocan run into two modes: dialog and prompt.Dialog modefrom 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 modefrom 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)ContributingIf you want to contribute to the project, you can submit bugs, feature requests or fork the github repository and submit your pull request.Licenseinterrogatiois released under theBSD 3-Clause "New" or "Revised" License.