From 2188390a3ebb21f9daf884eb01bb860665d8ed41 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 11:11:43 +0000 Subject: [PATCH] Add devterm tools and TUI menu --- devterm/tui/menu.py | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 devterm/tui/menu.py diff --git a/devterm/tui/menu.py b/devterm/tui/menu.py new file mode 100644 index 0000000..9810fad --- /dev/null +++ b/devterm/tui/menu.py @@ -0,0 +1,63 @@ +from rich.console import Console +from rich.panel import Panel +from rich.prompt import Prompt +from rich.table import Table + + +class DevtermMenu: + def __init__(self): + self.console = Console() + self.tools = [ + ("json", "JSON Formatter/Validator"), + ("jwt", "JWT Decoder"), + ("cron", "Cron Validator"), + ("base64", "Base64 Encoder/Decoder"), + ("url", "URL Encoder/Decoder"), + ] + + def display_welcome(self): + welcome_text = """ +[bold cyan]╔════════════════════════════════════════════════════════════╗ +║ [yellow]Devterm[/yellow] - Developer Tools ║ +║ ║ +║ A browser-based developer utilities suite ║ +║ Running at: http://{host}:{port} ║ +╚════════════════════════════════════════════════════════════╝[/bold cyan]""" + self.console.print(welcome_text) + + def display_menu(self): + table = Table(title="Available Tools", show_header=True, header_style="bold magenta") + table.add_column("#", justify="right", style="cyan") + table.add_column("Tool", justify="left", style="green") + table.add_column("Description", justify="left", style="white") + + for idx, (tool_id, description) in enumerate(self.tools, 1): + table.add_row(str(idx), f"[bold]{tool_id}[/bold]", description) + + self.console.print(Panel(table, title="[bold]Devterm Menu[/bold]", expand=False)) + + def get_user_choice(self): + self.display_welcome() + self.console.print() + self.display_menu() + self.console.print() + + choices = [str(i) for i in range(1, len(self.tools) + 1)] + choice = Prompt.ask( + "Select a tool to launch (or press Enter to open all in browser)", + choices=choices + [""], + default="", + ) + + if choice == "": + return None + return self.tools[int(choice) - 1][0] + + def show_starting_message(self, host: str, port: int): + self.console.print(Panel( + f"[green]Devterm is starting...[/green]\n\n" + f"Access tools at: [bold]http://{host}:{port}[/bold]\n\n" + f"Press [cyan]Ctrl+C[/cyan] to stop the server", + title="[bold]Devterm[/bold]", + expand=False + ))