55import sys
66
77sys .path .append (os .path .realpath ("." ))
8- import inquirer # noqa
8+ import inquirer
99
1010# Take authentication input from the user
1111questions = [
2020
2121# Just making pipelines
2222class Validation :
23- def phone_validation ():
23+ @staticmethod
24+ def phone_validation (answer , current ):
2425 # Think over how to make a validation for phone number?
25- pass
26+ return True
2627
27- def email_validation ():
28- pass
28+ @staticmethod
29+ def email_validation (answer , current ):
30+ return True
2931
30- def password_validation ():
31- pass
32+ @staticmethod
33+ def password_validation (answer , current ):
34+ return True
3235
36+ @staticmethod
3337 def username_validation ():
3438 pass
3539
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 ):
3752 # All the countries in the world???
3853 # JSON can be used.
3954 # Download the file
55+ return True
4056
41- def state_validation ():
57+ @staticmethod
58+ def state_validation (answer , current ):
4259 # All the states in the world??
4360 # The state of the selected country only.
44- pass
61+ return True
4562
46- def city_validation ():
63+ @staticmethod
64+ def city_validation (answer , current ):
4765 # All the cities in the world??
4866 # 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
5081
82+ @staticmethod
83+ def login_password (answer , current ):
84+ # Add your password validation logic here
85+ return True
5186
5287# Have an option to go back.
5388# How can I do it?
54- if answers ["authentication" ] == "Login" :
55- print ("Login" )
89+ if answers is not None and answers .get ("authentication" ) == "Login" :
5690 questions = [
91+ inquirer .
92+ Text (
93+ "surname" ,
94+ message = "What's your last name (surname)?" ,
95+ validate = Validation .lname_validation ,
96+ ),
5797 inquirer .Text (
5898 "username" ,
5999 message = "What's your username?" ,
@@ -65,11 +105,10 @@ def city_validation():
65105 validate = Validation .login_password ,
66106 ),
67107 ]
108+ answers = inquirer .prompt (questions )
68109
69-
70- elif answers ["authentication" ] == "Sign up" :
110+ elif answers is not None and answers .get ("authentication" ) == "Sign up" :
71111 print ("Sign up" )
72-
73112 questions = [
74113 inquirer .Text (
75114 "name" ,
@@ -78,7 +117,8 @@ def city_validation():
78117 ),
79118 inquirer .Text (
80119 "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 ,
82122 ),
83123 inquirer .Text (
84124 "phone" ,
@@ -96,7 +136,7 @@ def city_validation():
96136 validate = Validation .password_validation ,
97137 ),
98138 inquirer .Text (
99- "password " ,
139+ "password_confirm " ,
100140 message = "Confirm your password" ,
101141 validate = Validation .password_confirmation ,
102142 ),
@@ -110,27 +150,16 @@ def city_validation():
110150 message = "What's your country" ,
111151 validate = Validation .country_validation ,
112152 ),
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- ),
123153 inquirer .Text (
124154 "address" ,
125155 message = "What's your address" ,
126156 validate = Validation .address_validation ,
127157 ),
128158 ]
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" :
133162 print ("Exit" )
134163 sys .exit ()
135164
136- pprint (answers )
165+ pprint (answers )
0 commit comments