File: list.py

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 (34 lines) | stat: -rw-r--r-- 972 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
from InquirerPy import prompt
from InquirerPy.base.control import Choice
from InquirerPy.separator import Separator


def main():
    questions = [
        {
            "type": "list",
            "message": "Select an action:",
            "choices": ["Upload", "Download", Choice(value=None, name="Exit")],
            "default": None,
        },
        {
            "type": "list",
            "message": "Select regions:",
            "choices": [
                Choice("ap-southeast-2", name="Sydney"),
                Choice("ap-southeast-1", name="Singapore"),
                Separator(),
                "us-east-1",
                "us-east-2",
            ],
            "multiselect": True,
            "transformer": lambda result: f"{len(result)} region{'s' if len(result) > 1 else ''} selected",
            "when": lambda result: result[0] is not None,
        },
    ]

    result = prompt(questions=questions)


if __name__ == "__main__":
    main()