forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_master.py
More file actions
164 lines (142 loc) · 4.2 KB
/
cli_master.py
File metadata and controls
164 lines (142 loc) · 4.2 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import os
import sys
from pprint import pprint
sys.path.append(os.path.realpath("."))
import inquirer
# Take authentication input from the user
questions = [
inquirer.List(
"authentication", # This is the key
message="Choose an option",
choices=["Login", "Sign up", "Exit"],
),
]
answers = inquirer.prompt(questions)
# Just making pipelines
class Validation:
@staticmethod
def phone_validation(answer, current):
# Think over how to make a validation for phone number?
return True
@staticmethod
def email_validation(answer, current):
return True
@staticmethod
def password_validation(answer, current):
return True
@staticmethod
def username_validation():
pass
@staticmethod
def fname_validation(answer, current):
# Add your first name validation logic here
return True
@staticmethod
def lname_validation(answer, current):
# Add your last name validation logic here
return True
@staticmethod
def country_validation(answer, current):
# All the countries in the world???
# JSON can be used.
# Download the file
return True
@staticmethod
def state_validation(answer, current):
# All the states in the world??
# The state of the selected country only.
return True
@staticmethod
def city_validation(answer, current):
# All the cities in the world??
# JSON can be used.
return True
@staticmethod
def password_confirmation(answer, current):
return True
@staticmethod
def address_validation(answer, current):
return True
@staticmethod
def login_username(answer, current):
# Add your username validation logic here
return True
@staticmethod
def login_password(answer, current):
# Add your password validation logic here
return True
# Have an option to go back.
# How can I do it?
if answers is not None and answers.get("authentication") == "Login":
questions = [
inquirer.Text(
"surname",
message="What's your last name (surname)?",
validate=Validation.lname_validation,
),
inquirer.Text(
"username",
message="What's your username?",
validate=Validation.login_username,
),
inquirer.Text(
"password",
message="What's your password?",
validate=Validation.login_password,
),
]
answers = inquirer.prompt(questions)
elif answers is not None and answers.get("authentication") == "Sign up":
print("Sign up")
questions = [
inquirer.Text(
"name",
message="What's your first name?",
validate=Validation.fname_validation,
),
inquirer.Text(
"surname",
message="What's your last name (surname)?",
validate=Validation.lname_validation,
),
inquirer.Text(
"phone",
message="What's your phone number",
validate=Validation.phone_validation,
),
inquirer.Text(
"email",
message="What's your email",
validate=Validation.email_validation,
),
inquirer.Text(
"password",
message="What's your password",
validate=Validation.password_validation,
),
inquirer.Text(
"password_confirm",
message="Confirm your password",
validate=Validation.password_confirmation,
),
inquirer.Text(
"username",
message="What's your username",
validate=Validation.username_validation,
),
inquirer.Text(
"country",
message="What's your country",
validate=Validation.country_validation,
),
inquirer.Text(
"address",
message="What's your address",
validate=Validation.address_validation,
),
]
answers = inquirer.prompt(questions)
elif answers is not None and answers.get("authentication") == "Exit":
print("Exit")
sys.exit()
pprint(answers)