Added shelter and things needed for it (incomplete)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import questionary
|
||||
|
||||
|
||||
def clear():
|
||||
@@ -8,3 +9,23 @@ def clear():
|
||||
def title():
|
||||
clear()
|
||||
print("=== Whiskerbound ===\n")
|
||||
|
||||
|
||||
STYLE = questionary.Style(
|
||||
[
|
||||
("selected", "fg:cyan bold"),
|
||||
("pointer", "fg:cyan bold"),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def select(message, choices):
|
||||
return questionary.select(message, choices=choices, style=STYLE).ask()
|
||||
|
||||
|
||||
def text(message, default=""):
|
||||
return questionary.text(message, default=default, style=STYLE).ask()
|
||||
|
||||
|
||||
def confirm(message, default=True):
|
||||
return questionary.confirm(message, default=default, style=STYLE).ask()
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
from data.cat import Cat
|
||||
import systems.ui as ui
|
||||
import re
|
||||
|
||||
|
||||
def check_cat_name(name):
|
||||
name = name.strip()
|
||||
if not name:
|
||||
return "Please choose a name:"
|
||||
if len(name) > 4 or len(name) < 20:
|
||||
return "Please choose a name greater than 4 charecters and less than 20:"
|
||||
if re.search(r"[^a-zA-Z \-']", name):
|
||||
return "Please only use letters, spaces, hyphens and apostrophes:"
|
||||
return "Ok"
|
||||
|
||||
|
||||
def shelter():
|
||||
# TODO: make
|
||||
name = input("Name your cat: ")
|
||||
name = ui.text("Welcome to the shelter! Please choose a name for your cat:")
|
||||
while True:
|
||||
check_result = check_cat_name(name)
|
||||
if check_result != "Ok":
|
||||
name = ui.text(check_result)
|
||||
else:
|
||||
break
|
||||
return Cat(name)
|
||||
|
||||
Reference in New Issue
Block a user