File: input.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 (35 lines) | stat: -rw-r--r-- 946 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
from InquirerPy import prompt
from InquirerPy.validator import NumberValidator


def main():
    """Classic syntax example."""
    questions = [
        {"type": "input", "message": "Enter your name:"},
        {
            "type": "input",
            "message": "Which company would you like to apply:",
            "completer": {
                "Google": None,
                "Facebook": None,
                "Amazon": None,
                "Netflix": None,
                "Apple": None,
                "Microsoft": None,
            },
            "multicolumn_complete": True,
        },
        {
            "type": "input",
            "message": "What's your salary expectation(k):",
            "transformer": lambda result: "%sk" % result,
            "filter": lambda result: int(result) * 1000,
            "validate": NumberValidator(),
        },
    ]

    result = prompt(questions)


if __name__ == "__main__":
    main()