File: inquirer.md

package info (click to toggle)
python-inquirerpy 0.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,088 kB
  • sloc: python: 9,463; makefile: 15
file content (60 lines) | stat: -rw-r--r-- 1,261 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# inquirer

````{attention}
This document is irrelevant if you intend to use the {ref}`index:Classic Syntax (PyInquirer)`.

```{seealso}
{ref}`pages/prompt:prompt`
```

````

This page documents the usage of `inquirer`.

```{eval-rst}
.. automodule:: InquirerPy.inquirer
    :noindex:
```

An example using `inquirer` which incorporate multiple different types of prompts:

![demo](https://assets.kazhala.me/InquirerPy/InquirerPy-prompt.gif)

```{eval-rst}
.. literalinclude :: ../../examples/inquirer.py
   :language: python
```

```{important}
The `inquirer` module serves as an entry point to each prompt classes. Refer to
individual prompt documentation for prompt specific usage.
```

## Synchronous execution

Each prompt contains a function `execute` to start the prompt.

```{code-block} python
from InquirerPy import inquirer

def main():
  result = inquirer.text(message="Name:").execute()

if __name__ == "__main__":
  main()
```

## Asynchronous execution

Each prompt contains a function `execute_async` to start the prompt asynchronously.

```{code-block} python
import asyncio
from InquirerPy import inquirer

async def main():
  result = await inquirer.text(message="Name:").execute_async()

if __name__ == "__main__":
  asyncio.run(main())
```