From b65a14dec8f8f7992b07fb109413694bbfad3701 Mon Sep 17 00:00:00 2001 From: Vince Salvino Date: Wed, 19 Oct 2022 16:55:41 -0400 Subject: [PATCH] Show correct URL based on env --- cr/api.py | 8 ++++++++ cr/cli.py | 7 +++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cr/api.py b/cr/api.py index d29b309..1274356 100644 --- a/cr/api.py +++ b/cr/api.py @@ -89,6 +89,14 @@ def __init__(self, handle: str, token: str): db_type=DatabaseType(dbdict["db_type"]), ) + def url(self, env: Env) -> str: + """ + Return the URL of this website based on environment. + """ + if env == Env.STAGING: + return f"https://{self.handle}.staging.codered.cloud/" + return self.primary_url + def local_check_path(self, p: Path, c: Optional[Console]) -> None: """ Validity check for a provided Path ``p``. If Console ``c`` is provided, diff --git a/cr/cli.py b/cr/cli.py index c9bd3cb..6e01c1b 100644 --- a/cr/cli.py +++ b/cr/cli.py @@ -309,7 +309,7 @@ def run(self, args: argparse.Namespace): ) pbar.update(t, total=1, completed=1) - CONSOLE.print(f"\nYour site is live at: {w.primary_url}\n") + CONSOLE.print(f"\nYour site is live at: {w.url(args.env)}\n") class Restart(Command): @@ -332,9 +332,8 @@ def run(self, args: argparse.Namespace): w = self.get_webapp(args) w.api_queue_restart(args.env) CONSOLE.print( - "Restart in progress. You will receive an email when complete." - "\n\n" - f"Restarting: {w.primary_url}" + f"Restarting: {w.url(args.env)}\n" + "You will receive an email when complete." )