Skip to content

Commit b3bca44

Browse files
committed
Clean up logo printing code
1 parent 43855b4 commit b3bca44

File tree

2 files changed

+57
-119
lines changed

2 files changed

+57
-119
lines changed

src/mcpm/cli.py

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"""
44

55
# Import rich-click configuration before anything else
6+
from typing import Any, Dict
7+
68
from rich.console import Console
79
from rich.traceback import Traceback
810

9-
from mcpm import __version__
1011
from mcpm.clients.client_config import ClientConfigManager
1112
from mcpm.commands import (
1213
add,
@@ -27,7 +28,7 @@
2728
from mcpm.commands.share import share
2829
from mcpm.migration import V1ConfigDetector, V1ToV2Migrator
2930
from mcpm.utils.logging_config import setup_logging
30-
from mcpm.utils.rich_click_config import click, get_footer_text, get_header_text
31+
from mcpm.utils.rich_click_config import click, get_header_text
3132

3233
console = Console()
3334
client_config_manager = ClientConfigManager()
@@ -36,72 +37,12 @@
3637
setup_logging()
3738

3839
# Custom context settings to handle main command help specially
39-
CONTEXT_SETTINGS = dict(help_option_names=[])
40+
CONTEXT_SETTINGS: Dict[str, Any] = dict(help_option_names=[])
4041

4142

4243
def print_logo():
4344
"""Print an elegant gradient logo with invisible Panel for width control"""
44-
from rich import box
45-
from rich.console import Group
46-
from rich.panel import Panel
47-
from rich.text import Text
48-
from rich_gradient import Gradient
49-
50-
# Clean ASCII art design - simplified with light shades
51-
logo_text = """
52-
███░ ███░ ██████░ ██████░ ███░ ███░
53-
████░ ████░ ██░░░░░░ ██░░░██░ ████░ ████░
54-
██░████░██░ ██░ ██████░░ ██░████░██░
55-
██░░██░░██░ ██░ ██░░░░░ ██░░██░░██░
56-
██░ ░░░ ██░ ░██████░ ██░ ██░ ░░░ ██░
57-
░░░ ░░░ ░░░░░░░ ░░░ ░░░ ░░░
58-
59-
"""
60-
61-
# Purple-to-pink gradient palette
62-
primary_colors = ["#8F87F1", "#C68EFD", "#E9A5F1", "#FED2E2"]
63-
64-
# Create gradient using rich-gradient with narrow console for better gradient distribution
65-
temp_console = Console(width=50) # Close to ASCII art width
66-
logo_gradient_obj = Gradient(logo_text, colors=primary_colors)
67-
68-
# Capture the rendered gradient
69-
with temp_console.capture() as capture:
70-
temp_console.print(logo_gradient_obj, justify="center")
71-
logo_gradient = Text.from_ansi(capture.get())
72-
73-
# Create solid color text for title and tagline - harmonized with gradient
74-
title_text = Text()
75-
title_text.append("Model Context Protocol Manager", style="#8F87F1 bold")
76-
title_text.append(" v", style="#C68EFD")
77-
title_text.append(__version__, style="#E9A5F1 bold")
78-
79-
tagline_text = Text()
80-
tagline_text.append("Open Source with ", style="#FED2E2")
81-
tagline_text.append("♥", style="#E9A5F1")
82-
tagline_text.append(" by Path Integral Institute", style="#FED2E2")
83-
84-
# Create content group with proper spacing - all left aligned for consistency
85-
content = Group(
86-
"", # Empty line at top
87-
logo_gradient,
88-
"",
89-
title_text,
90-
"",
91-
tagline_text,
92-
"", # Empty line at bottom
93-
)
94-
95-
# Create invisible panel for width constraint only
96-
invisible_panel = Panel(
97-
content,
98-
width=120,
99-
box=box.SIMPLE, # Simple box style
100-
border_style="dim", # Very dim border
101-
padding=(0, 1),
102-
)
103-
104-
console.print(invisible_panel)
45+
console.print(get_header_text())
10546

10647

10748
def handle_exceptions(func):
@@ -150,7 +91,6 @@ def main(ctx, version, help_flag):
15091
click.rich_click.FOOTER_TEXT = None
15192
click.echo(ctx.get_help())
15293
click.rich_click.FOOTER_TEXT = original_footer
153-
console.print(get_footer_text())
15494
return
15595

15696
# Check for v1 configuration and offer migration (even with subcommands)
@@ -174,7 +114,6 @@ def main(ctx, version, help_flag):
174114
click.rich_click.FOOTER_TEXT = None
175115
click.echo(ctx.get_help())
176116
click.rich_click.FOOTER_TEXT = original_footer
177-
console.print(get_footer_text())
178117

179118

180119
# Register v2.0 commands

src/mcpm/utils/rich_click_config.py

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,60 @@
1818

1919
# Get version dynamically
2020

21-
# ASCII art logo - simplified with light shades
22-
ASCII_ART = """
23-
███░ ███░ ██████░ ██████░ ███░ ███░
24-
████░ ████░ ██░░░░░░ ██░░░██░ ████░ ████░
25-
██░████░██░ ██░ ██████░░ ██░████░██░
26-
██░░██░░██░ ██░ ██░░░░░ ██░░██░░██░
27-
██░ ░░░ ██░ ░██████░ ██░ ██░ ░░░ ██░
28-
░░░ ░░░ ░░░░░░░ ░░░ ░░░ ░░░
29-
30-
"""
31-
32-
# Create an elegant logo with ocean-to-sunset gradient using rich.text.Text
33-
header_text = Text()
34-
35-
# Create gradient ASCII art using rich-gradient with purple-to-pink colors
36-
gradient_colors = ["#8F87F1", "#C68EFD", "#E9A5F1", "#FED2E2"]
37-
38-
# Create a console with narrower width to force gradient calculation over ASCII width
39-
temp_console = Console(width=50) # Close to ASCII art width
40-
41-
# Create gradient and render it with the narrow console
42-
ascii_gradient = Gradient(ASCII_ART, colors=gradient_colors)
43-
44-
# Capture the rendered gradient
45-
with temp_console.capture() as capture:
46-
temp_console.print(ascii_gradient, justify="center")
47-
rendered_ascii = capture.get()
48-
49-
# Add to header text
50-
header_text = Text.from_ansi(rendered_ascii)
51-
52-
header_text.append("\n")
53-
54-
# Add solid color text for title and tagline - harmonized with gradient
55-
header_text.append("Model Context Protocol Manager", style="#8F87F1 bold")
56-
header_text.append(" v", style="#C68EFD")
57-
header_text.append(__version__, style="#E9A5F1 bold")
58-
header_text.append("\n")
59-
header_text.append("Open Source with ", style="#FED2E2")
60-
header_text.append("♥", style="#E9A5F1")
61-
header_text.append(" by Path Integral Institute", style="#FED2E2")
62-
63-
footer_text = Text()
64-
footer_text.append("")
65-
6621

6722
# Export header and footer for use in main command
6823
def get_header_text():
24+
# ASCII art logo - simplified with light shades
25+
ASCII_ART = """
26+
███░ ███░ ██████░ ██████░ ███░ ███░
27+
████░ ████░ ██░░░░░░ ██░░░██░ ████░ ████░
28+
██░████░██░ ██░ ██████░░ ██░████░██░
29+
██░░██░░██░ ██░ ██░░░░░ ██░░██░░██░
30+
██░ ░░░ ██░ ░██████░ ██░ ██░ ░░░ ██░
31+
░░░ ░░░ ░░░░░░░ ░░░ ░░░ ░░░
32+
33+
"""
34+
35+
# Create an elegant logo with ocean-to-sunset gradient using rich.text.Text
36+
header_text = Text()
37+
38+
# Create gradient ASCII art using rich-gradient with purple-to-pink colors
39+
gradient_colors = ["#8F87F1", "#C68EFD", "#E9A5F1", "#FED2E2"]
40+
41+
# Create a console with narrower width to force gradient calculation over ASCII width
42+
temp_console = Console(width=80) # Close to ASCII art width
43+
44+
# Create gradient and render it with the narrow console
45+
ascii_gradient = Gradient(ASCII_ART, colors=gradient_colors) # type: ignore
46+
47+
# Capture the rendered gradient
48+
with temp_console.capture() as capture:
49+
temp_console.print(ascii_gradient, justify="center")
50+
rendered_ascii = capture.get()
51+
52+
# Add to header text
53+
header_text = Text.from_ansi(rendered_ascii)
54+
55+
header_text.append("\n")
56+
57+
# Add solid color text for title and tagline - harmonized with gradient
58+
prose = Text()
59+
prose.append("Model Context Protocol Manager", style="#8F87F1 bold")
60+
prose.append(" v", style="#C68EFD")
61+
prose.append(__version__, style="#E9A5F1 bold")
62+
prose.append("\n")
63+
prose.append("Open Source with ", style="#FED2E2")
64+
prose.append("♥", style="#E9A5F1")
65+
prose.append(" by Path Integral Institute", style="#FED2E2")
66+
67+
with temp_console.capture() as capture:
68+
temp_console.print(prose, justify="center")
69+
rendered_text = capture.get().rstrip()
70+
71+
header_text.append(Text.from_ansi(rendered_text))
6972
return header_text
7073

7174

72-
def get_footer_text():
73-
return footer_text
74-
75-
7675
# Add subtle footer to all commands using Text object to avoid literal markup
7776
global_footer_text = Text()
7877
global_footer_text.append("💬 Report bugs or request features: ", style="#8B7DB8")
@@ -85,8 +84,8 @@ def get_footer_text():
8584
click.rich_click.SHOW_METAVARS_COLUMN = False
8685
click.rich_click.APPEND_METAVARS_HELP = True
8786
click.rich_click.SHOW_ARGUMENTS = True
88-
click.rich_click.SHOW_HELP_FOR_ORPHAN_COMMAND = False
89-
click.rich_click.GROUP_COMMANDS_BEFORE_USAGE = True
87+
# click.rich_click.SHOW_HELP_FOR_ORPHAN_COMMAND = False
88+
# click.rich_click.GROUP_COMMANDS_BEFORE_USAGE = True
9089

9190
# Command groups for organized help
9291
click.rich_click.COMMAND_GROUPS = {
@@ -147,15 +146,15 @@ def get_footer_text():
147146
click.rich_click.STYLE_COMMAND = "bold cyan"
148147
click.rich_click.STYLE_SWITCH = "bold green"
149148
click.rich_click.STYLE_METAVAR = "bold yellow"
150-
click.rich_click.STYLE_METAVAR_BRACKET = "dim"
149+
# click.rich_click.STYLE_METAVAR_BRACKET = "dim"
151150
click.rich_click.STYLE_HELPTEXT = ""
152151
click.rich_click.STYLE_HELPTEXT_FIRST_LINE = "bold"
153152
click.rich_click.STYLE_OPTION_HELP = ""
154153
click.rich_click.STYLE_USAGE = "bold"
155154
click.rich_click.STYLE_USAGE_COMMAND = "bold cyan"
156155

157156
# Layout
158-
click.rich_click.ALIGN_ERRORS_LEFT = True
157+
# click.rich_click.ALIGN_ERRORS_LEFT = True
159158
click.rich_click.WIDTH = None # Use terminal width
160159
click.rich_click.MAX_WIDTH = 100 # Maximum width for better readability
161160

0 commit comments

Comments
 (0)