diff --git a/service.py b/service.py index ae077b8..e35d12e 100644 --- a/service.py +++ b/service.py @@ -5,6 +5,7 @@ from os import path import subprocess as sub import re from typing import Any, Callable +from enum import Enum P_BANNER = """ ██╗ ██╗███████╗██╗ ██╗ ██╗ ██████╗ ███╗ ███╗ @@ -23,6 +24,13 @@ Opties: 3) Recover omgeving(en) 4) List omgeving(en) """ +class PortalOptions(Enum): + EXIT = "0" + CREATE = "1" + DESTROY = "2" + RECOVER = "3" + LIST = "4" + RE_TEXT = re.compile(r"^\w+$") RE_NUM = re.compile(r"^\d+$") @@ -89,16 +97,16 @@ def main() -> int: p = Prompter(ps1=f"{customer_name} > ") while True: print(P_OPTIONS) - c = p.take_input("Keuze: ", RE_ANY) + choice = p.take_input("Keuze: ", RE_ANY) print(end="\n") - if c == "0": + if choice == PortalOptions.EXIT.value: """ Used to break out of the loop and exit the portal. """ break - if c == "1": + if choice == PortalOptions.CREATE.value: """ Used to either update or create an environment. """ @@ -159,7 +167,7 @@ def main() -> int: ]) print(f"Omgeving `{env_name}` successvol gemaakt.") - if c == "2": + if choice == PortalOptions.DESTROY.value: """ Deletes all traces of the chosen environment. """ @@ -168,7 +176,7 @@ def main() -> int: env_name = p.take_choice(fmt, envs) sub.call(["python3", "cli.py", "delete", customer_name, env_name]) - if c == "3": + if choice == PortalOptions.RECOVER.value: """ Allows the customer to "force" their environment into the desired `up-state`. This `up-state` is a representation of the Vagrantfile, Ansible inventory and @@ -181,7 +189,7 @@ def main() -> int: env_name = p.take_choice(fmt, envs) sub.call(["python3", "cli.py", "recover", customer_name, env_name]) - if c == "4": + if choice == PortalOptions.LIST.value: """ This branch displays the customer's existing environments """