5
5
import sys
6
6
7
7
sys .path .append (os .path .realpath ("." ))
8
- import inquirer # noqa
8
+ import inquirer
9
9
10
10
# Take authentication input from the user
11
11
questions = [
20
20
21
21
# Just making pipelines
22
22
class Validation :
23
- def phone_validation ():
23
+ @staticmethod
24
+ def phone_validation (answer , current ):
24
25
# Think over how to make a validation for phone number?
25
- pass
26
+ return True
26
27
27
- def email_validation ():
28
- pass
28
+ @staticmethod
29
+ def email_validation (answer , current ):
30
+ return True
29
31
30
- def password_validation ():
31
- pass
32
+ @staticmethod
33
+ def password_validation (answer , current ):
34
+ return True
32
35
36
+ @staticmethod
33
37
def username_validation ():
34
38
pass
35
39
36
- def country_validation ():
40
+ @staticmethod
41
+ def fname_validation (answer , current ):
42
+ # Add your first name validation logic here
43
+ return True
44
+
45
+ @staticmethod
46
+ def lname_validation (answer , current ):
47
+ # Add your last name validation logic here
48
+ return True
49
+
50
+ @staticmethod
51
+ def country_validation (answer , current ):
37
52
# All the countries in the world???
38
53
# JSON can be used.
39
54
# Download the file
55
+ return True
40
56
41
- def state_validation ():
57
+ @staticmethod
58
+ def state_validation (answer , current ):
42
59
# All the states in the world??
43
60
# The state of the selected country only.
44
- pass
61
+ return True
45
62
46
- def city_validation ():
63
+ @staticmethod
64
+ def city_validation (answer , current ):
47
65
# All the cities in the world??
48
66
# JSON can be used.
49
- pass
67
+ return True
68
+
69
+ @staticmethod
70
+ def password_confirmation (answer , current ):
71
+ return True
72
+
73
+ @staticmethod
74
+ def address_validation (answer , current ):
75
+ return True
76
+
77
+ @staticmethod
78
+ def login_username (answer , current ):
79
+ # Add your username validation logic here
80
+ return True
50
81
82
+ @staticmethod
83
+ def login_password (answer , current ):
84
+ # Add your password validation logic here
85
+ return True
51
86
52
87
# Have an option to go back.
53
88
# How can I do it?
54
- if answers ["authentication" ] == "Login" :
55
- print ("Login" )
89
+ if answers is not None and answers .get ("authentication" ) == "Login" :
56
90
questions = [
91
+ inquirer .
92
+ Text (
93
+ "surname" ,
94
+ message = "What's your last name (surname)?" ,
95
+ validate = Validation .lname_validation ,
96
+ ),
57
97
inquirer .Text (
58
98
"username" ,
59
99
message = "What's your username?" ,
@@ -65,11 +105,10 @@ def city_validation():
65
105
validate = Validation .login_password ,
66
106
),
67
107
]
108
+ answers = inquirer .prompt (questions )
68
109
69
-
70
- elif answers ["authentication" ] == "Sign up" :
110
+ elif answers is not None and answers .get ("authentication" ) == "Sign up" :
71
111
print ("Sign up" )
72
-
73
112
questions = [
74
113
inquirer .Text (
75
114
"name" ,
@@ -78,7 +117,8 @@ def city_validation():
78
117
),
79
118
inquirer .Text (
80
119
"surname" ,
81
- message = "What's your last name(surname)?, validate=Validation.lname), {name}?" ,
120
+ message = "What's your last name (surname)?" ,
121
+ validate = Validation .lname_validation ,
82
122
),
83
123
inquirer .Text (
84
124
"phone" ,
@@ -96,7 +136,7 @@ def city_validation():
96
136
validate = Validation .password_validation ,
97
137
),
98
138
inquirer .Text (
99
- "password " ,
139
+ "password_confirm " ,
100
140
message = "Confirm your password" ,
101
141
validate = Validation .password_confirmation ,
102
142
),
@@ -110,27 +150,16 @@ def city_validation():
110
150
message = "What's your country" ,
111
151
validate = Validation .country_validation ,
112
152
),
113
- inquirer .Text (
114
- "state" ,
115
- message = "What's your state" ,
116
- validate = Validation .state_validation ,
117
- ),
118
- inquirer .Text (
119
- "city" ,
120
- message = "What's your city" ,
121
- validate = Validation .city_validation ,
122
- ),
123
153
inquirer .Text (
124
154
"address" ,
125
155
message = "What's your address" ,
126
156
validate = Validation .address_validation ,
127
157
),
128
158
]
129
- # Also add optional in the above thing.
130
- # Have string manipulation for the above thing.
131
- # How to add authentication of google to command line?
132
- elif answers ["authentication" ] == "Exit" :
159
+ answers = inquirer .prompt (questions )
160
+
161
+ elif answers is not None and answers .get ("authentication" ) == "Exit" :
133
162
print ("Exit" )
134
163
sys .exit ()
135
164
136
- pprint (answers )
165
+ pprint (answers )
0 commit comments