|
| 1 | +import os |
| 2 | +import sys |
| 3 | +from pprint import pprint |
| 4 | + |
| 5 | +import sys |
| 6 | + |
| 7 | +sys.path.append(os.path.realpath(".")) |
| 8 | +import inquirer # noqa |
| 9 | + |
| 10 | +# Take authentication input from the user |
| 11 | +questions = [ |
| 12 | + inquirer.List( |
| 13 | + "authentication", # This is the key |
| 14 | + message="Choose an option", |
| 15 | + choices=["Login", "Sign up", "Exit"], |
| 16 | + ), |
| 17 | +] |
| 18 | +answers = inquirer.prompt(questions) |
| 19 | + |
| 20 | + |
| 21 | +# Just making pipelines |
| 22 | +class Validation: |
| 23 | + def phone_validation(): |
| 24 | + # Think over how to make a validation for phone number? |
| 25 | + pass |
| 26 | + |
| 27 | + def email_validation(): |
| 28 | + pass |
| 29 | + |
| 30 | + def password_validation(): |
| 31 | + pass |
| 32 | + |
| 33 | + def username_validation(): |
| 34 | + pass |
| 35 | + |
| 36 | + def country_validation(): |
| 37 | + # All the countries in the world??? |
| 38 | + # JSON can be used. |
| 39 | + # Download the file |
| 40 | + |
| 41 | + def state_validation(): |
| 42 | + # All the states in the world?? |
| 43 | + # The state of the selected country only. |
| 44 | + pass |
| 45 | + |
| 46 | + def city_validation(): |
| 47 | + # All the cities in the world?? |
| 48 | + # JSON can be used. |
| 49 | + pass |
| 50 | + |
| 51 | + |
| 52 | +# Have an option to go back. |
| 53 | +# How can I do it? |
| 54 | +if answers["authentication"] == "Login": |
| 55 | + print("Login") |
| 56 | + questions = [ |
| 57 | + inquirer.Text( |
| 58 | + "username", |
| 59 | + message="What's your username?", |
| 60 | + validate=Validation.login_username, |
| 61 | + ), |
| 62 | + inquirer.Text( |
| 63 | + "password", |
| 64 | + message="What's your password?", |
| 65 | + validate=Validation.login_password, |
| 66 | + ), |
| 67 | + ] |
| 68 | + |
| 69 | + |
| 70 | +elif answers["authentication"] == "Sign up": |
| 71 | + print("Sign up") |
| 72 | + |
| 73 | + questions = [ |
| 74 | + inquirer.Text( |
| 75 | + "name", |
| 76 | + message="What's your first name?", |
| 77 | + validate=Validation.fname_validation, |
| 78 | + ), |
| 79 | + inquirer.Text( |
| 80 | + "surname", |
| 81 | + message="What's your last name(surname)?, validate=Validation.lname), {name}?", |
| 82 | + ), |
| 83 | + inquirer.Text( |
| 84 | + "phone", |
| 85 | + message="What's your phone number", |
| 86 | + validate=Validation.phone_validation, |
| 87 | + ), |
| 88 | + inquirer.Text( |
| 89 | + "email", |
| 90 | + message="What's your email", |
| 91 | + validate=Validation.email_validation, |
| 92 | + ), |
| 93 | + inquirer.Text( |
| 94 | + "password", |
| 95 | + message="What's your password", |
| 96 | + validate=Validation.password_validation, |
| 97 | + ), |
| 98 | + inquirer.Text( |
| 99 | + "password", |
| 100 | + message="Confirm your password", |
| 101 | + validate=Validation.password_confirmation, |
| 102 | + ), |
| 103 | + inquirer.Text( |
| 104 | + "username", |
| 105 | + message="What's your username", |
| 106 | + validate=Validation.username_validation, |
| 107 | + ), |
| 108 | + inquirer.Text( |
| 109 | + "country", |
| 110 | + message="What's your country", |
| 111 | + validate=Validation.country_validation, |
| 112 | + ), |
| 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 | + inquirer.Text( |
| 124 | + "address", |
| 125 | + message="What's your address", |
| 126 | + validate=Validation.address_validation, |
| 127 | + ), |
| 128 | + ] |
| 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": |
| 133 | + print("Exit") |
| 134 | + sys.exit() |
| 135 | + |
| 136 | +pprint(answers) |
0 commit comments