From cfec9796efeb7d62e97e6dc4732ecaab5eeb6b88 Mon Sep 17 00:00:00 2001 From: iamDyeus Date: Tue, 19 Nov 2024 12:02:43 +0530 Subject: [PATCH] fix: Change Terminal Command Output Format to Align with Vite-Style Output | closes #22 Simple shit, just changed those print commands ; ) --- tkreload/help.py | 15 ++++++++------- tkreload/main.py | 14 +++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tkreload/help.py b/tkreload/help.py index fca690f..135d811 100644 --- a/tkreload/help.py +++ b/tkreload/help.py @@ -6,10 +6,11 @@ def show_help(auto_reload): """Displays help commands with detailed info and rich formatting.""" - console.print("\n[bold yellow]Tkreload Help:[/bold yellow]") - console.print("[bold blue]-----------------------------------------[/bold blue]") - console.print("[bold cyan]Enter + H[/bold cyan] : Display this help section.") - console.print("[bold cyan]Enter + R[/bold cyan] : Restart the Tkinter app.") - console.print("[bold cyan]Enter + A[/bold cyan] : Toggle auto-reload (currently [bold magenta]{}[/bold magenta]).".format("Enabled" if auto_reload else "Disabled")) - console.print("[bold red]Ctrl + C[/bold red] : Exit the development server.") - console.print("[bold blue]-----------------------------------------[/bold blue]\n") + console.print("\n[bold yellow]Tkreload Help:[/bold yellow] [dim](detailed command info)[/dim]\n") + console.print("[bold cyan]→[/bold cyan] [bold white]Press H[/bold white] : Display this help section.") + console.print("[bold cyan]→[/bold cyan] [bold white]Press R[/bold white] : Restart the Tkinter app.") + console.print( + f"[bold cyan]→[/bold cyan] [bold white]Press A[/bold white] : Toggle auto-reload " + f"(currently [bold magenta]{auto_reload}[/bold magenta])." + ) + console.print("[bold cyan]→[/bold cyan] [bold white]Ctrl + C[/bold white] : Exit the development server.\n") diff --git a/tkreload/main.py b/tkreload/main.py index fb4dcaf..48a0db4 100644 --- a/tkreload/main.py +++ b/tkreload/main.py @@ -28,6 +28,7 @@ def __init__(self, app_file): self.process = None self.observer = None self.reload_count = 0 + self.startup_time=0 def run_tkinter_app(self): """Run the given Tkinter app.""" @@ -65,18 +66,21 @@ def restart_app(self): def start(self): """Starts the application, including monitoring and handling commands.""" + start_time = time.time() # Record the start time self.run_tkinter_app() self.monitor_file_changes(self.restart_app) + self.startup_time = (time.time() - start_time) * 1000 # Calculate startup time in milliseconds try: self.console.print( - "\n\n\t[bold cyan]Tkreload[/bold cyan] [bold blue]is running ✅\n\t[/bold blue]- Press [bold cyan]H[/bold cyan] for help,\n\t[bold cyan]- R[/bold cyan] to restart,\n\t[bold cyan]- A[/bold cyan] to toggle auto-reload (currently [bold magenta]{}[/bold magenta]),\n\t[bold red]- Ctrl + C[/bold red] to exit.".format( - "Disabled" - if not self.auto_reload_manager.get_status() - else "Enabled" - ) + f"\n[bold white]Tkreload ✅[/bold white] [dim](ready in {self.startup_time:.2f} ms)[/dim]\n" + f"\t[bold cyan]→[/bold cyan] [bold white]Auto-reload:[/bold white] [bold magenta]{'Enabled' if self.auto_reload_manager.get_status() else 'Disabled'}[/bold magenta]\n" + "\t[bold cyan]→[/bold cyan] [bold white]Help:[/bold white] Press [bold cyan]H[/bold cyan]\n" + "\t[bold cyan]→[/bold cyan] [bold white]Restart:[/bold white] Press [bold cyan]R[/bold cyan]\n" + "\t[bold cyan]→[/bold cyan] [bold white]Exit:[/bold white] Press [bold red]Ctrl + C[/bold red]" ) + while True: if platform.system() == "Windows": if msvcrt.kbhit(): # Check for keyboard input (Windows only)