File: rawlist.py

package info (click to toggle)
python-inquirerpy 0.3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,088 kB
  • sloc: python: 9,463; makefile: 15
file content (37 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (2)
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
from InquirerPy import inquirer
from InquirerPy.base.control import Choice
from InquirerPy.separator import Separator


def main():
    fruit = inquirer.rawlist(
        message="Pick your favourites:",
        choices=[
            "Apple",
            "Orange",
            "Peach",
            "Cherry",
            "Melon",
            "Strawberry",
            "Grapes",
        ],
        default=3,
        multiselect=True,
        transformer=lambda result: ", ".join(result),
        validate=lambda result: len(result) > 1,
        invalid_message="Minimum 2 selections",
    ).execute()
    method = inquirer.rawlist(
        message="Select your preferred method:",
        choices=[
            Choice(name="Delivery", value="dl"),
            Choice(name="Pick Up", value="pk"),
            Separator(line=15 * "*"),
            Choice(name="Car Park", value="cp"),
            Choice(name="Third Party", value="tp"),
        ],
    ).execute()


if __name__ == "__main__":
    main()