From 7c6687c8883287dfc6abefcb400a15a88638bdeb Mon Sep 17 00:00:00 2001 From: m5rcel { Marcel } Date: Sat, 4 Oct 2025 11:50:35 +0200 Subject: [PATCH] Update cmd_credits.py --- commands/cmd_credits.py | 72 ++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/commands/cmd_credits.py b/commands/cmd_credits.py index 2524839..bb036b9 100644 --- a/commands/cmd_credits.py +++ b/commands/cmd_credits.py @@ -1,35 +1,47 @@ -# commands/cmd_credits.py from colorama import Fore, Style - - -class CreditsCommand: - def run(self): - box_width = 70 - title = "Credits" - - credits = [ - (f"{Fore.CYAN}m5rcel{Fore.RESET}", "Lead Developer"), - (f"{Fore.YELLOW}pythonjs.cfd{Fore.RESET}", "Project Hosting & Deployment"), - (f"{Fore.MAGENTA}colorama{Fore.RESET}", "Used for terminal styling"), - (f"{Fore.GREEN}fastfetch inspired{Fore.RESET}", "Design influence"), - (f"{Fore.RED}openai.com{Fore.RESET}", "Some smart AI help ;)"), - ] - - # Top border - print(Fore.MAGENTA + "╭" + "─" * (box_width - 2) + "╮") - print(Fore.MAGENTA + "│" + Fore.CYAN + f"{title:^{box_width - 2}}" + Fore.MAGENTA + "│") - print(Fore.MAGENTA + "├" + "─" * (box_width - 2) + "┤") - - # Content - for name, role in credits: - line = f"{name:<30} {Fore.WHITE}- {role}" - padding = box_width - 3 - len(strip_ansi(line)) - print(Fore.MAGENTA + "│ " + line + " " * padding + Fore.MAGENTA + "│") - - # Bottom border - print(Fore.MAGENTA + "╰" + "─" * (box_width - 2) + "╯" + Style.RESET_ALL) - +from pyfiglet import Figlet def strip_ansi(text): import re return re.sub(r'\x1b\[[0-9;]*m', '', text) + +class CreditsCommand: + def run(self): + box_width = 70 + inner_width = box_width - 2 + fig = Figlet(font='slant') + credits = [ + (f"{Style.BRIGHT}{Fore.CYAN}m5rcel{Style.RESET_ALL}", "Lead Developer"), + (f"{Style.BRIGHT}{Fore.YELLOW}pythonjs.cfd{Style.RESET_ALL}", "Project Hosting & Deployment"), + (f"{Style.BRIGHT}{Fore.MAGENTA}colorama{Style.RESET_ALL}", "Used for terminal styling"), + (f"{Style.BRIGHT}{Fore.GREEN}fastfetch inspired{Style.RESET_ALL}", "Design influence"), + (f"{Style.BRIGHT}{Fore.RED}openai.com{Style.RESET_ALL}", "Some smart AI help ;)"), + ] + + # Top border + print(Fore.MAGENTA + "╔" + "═" * inner_width + "╗") + + # Figlet "CREDITS" title, trimmed/padded and centered vertically + credits_title_lines = fig.renderText("CREDITS").splitlines() + for line in credits_title_lines: + if line.strip() == '': continue + raw = line[:inner_width] + pad = (inner_width - len(strip_ansi(raw))) // 2 + out = " " * pad + raw + out = out[:inner_width] + out = out + " " * (inner_width - len(strip_ansi(out))) + print(Fore.MAGENTA + "║" + Fore.LIGHTMAGENTA_EX + out + Fore.MAGENTA + "║") + print(Fore.MAGENTA + "╟" + "─" * inner_width + "╢") + + # Content, each line padded to match box width + for name, role in credits: + left = f"{name:<25}" + dash = f"{Fore.CYAN}━{Style.RESET_ALL}" + right = f"{Fore.LIGHTWHITE_EX}{role}{Style.RESET_ALL}" + raw_text = f"{left} {dash} {right}" + raw_len = len(strip_ansi(raw_text)) + line = raw_text + " " * (inner_width - raw_len) + print(Fore.MAGENTA + "║" + line + Fore.MAGENTA + "║") + + # Bottom border + print(Fore.MAGENTA + "╚" + "═" * inner_width + "╝" + Style.RESET_ALL)