Coverage for /Users/antonigmitruk/golf/src/golf/cli/branding.py: 0%

1"""Golf CLI branding and visual utilities."""

2

3 from rich.console import Console

4 from rich.panel import Panel

5 from rich.text import Text

6 from rich.align import Align

7

8# Golf brand colors (official brand colors)

9 GOLF_BLUE = "#2969FD" # Primary blue from brand: rgb(41, 105, 253)

10 GOLF_ORANGE = "#F97728" # Secondary orange from brand: rgb(249, 119, 40)

11 GOLF_GREEN = "#10B981" # Success green

12 GOLF_WHITE = "#FFFFFF"

13

14# Simple GolfMCP text logo

15 GOLF_LOGO = """

16 ██████╗ ██████╗ ██╗ ███████╗███╗ ███╗ ██████╗██████╗

17██╔════╝ ██╔═══██╗██║ ██╔════╝████╗ ████║██╔════╝██╔══██╗

18██║ ███╗██║ ██║██║ █████╗ ██╔████╔██║██║ ██████╔╝

19██║ ██║██║ ██║██║ ██╔══╝ ██║╚██╔╝██║██║ ██╔═══╝

20╚██████╔╝╚██████╔╝███████╗██║ ██║ ╚═╝ ██║╚██████╗██║

21 ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝

22"""

23

24# Simplified version for smaller spaces

25 GOLF_LOGO_SMALL = "Golf"

26

27# Status icons with consistent styling

28 STATUS_ICONS = {

29 "success": "✓",

30 "error": "✗",

31 "warning": "⚠",

32 "info": "ℹ",

33 "building": "🔨",

34 "generating": "⚙️",

35 "packaging": "📦",

36 "platform": "⛳",

37 "server": "🚀",

38 "loading": "⭕",

39}

40

41

42 def create_welcome_banner(version: str, console: Console) -> None:

43 """Create the main Golf welcome banner."""

44 # Create the logo with Golf in blue and MCP in orange

45 logo_lines = GOLF_LOGO.strip().split("\n")

46 logo_content = Text()

47

48 for line in logo_lines:

49 if line.strip(): # Only process non-empty lines

50 # Find where "MCP" starts (roughly at position 32 in the ASCII art)

51 golf_part = line[:32] # First part is "Golf"

52 mcp_part = line[32:] # Last part is "MCP"

53

54 logo_content.append(golf_part, style=f"bold {GOLF_BLUE}")

55 logo_content.append(mcp_part, style=f"bold {GOLF_ORANGE}")

56 logo_content.append("\n")

57

58 # Create version line

59 version_text = Text()

60 version_text.append("🚀 ", style=f"bold {GOLF_ORANGE}")

61 version_text.append(f"Golf v{version}", style=f"bold {GOLF_BLUE}")

62 version_text.append(" 🚀", style=f"bold {GOLF_ORANGE}")

63

64 # Create tagline

65 tagline_text = Text("✨ Easiest way to build production-ready MCP servers ✨", style="bold white")

66

67 # Create the full content using a renderable group approach

68 from rich.console import Group

69

70 content_group = Group(

71 Align.center(logo_content),

72 "", # Empty line for spacing

73 Align.center(version_text),

74 Align.center(tagline_text),

75 )

76

77 panel = Panel(

78 content_group,

79 border_style=GOLF_BLUE,

80 padding=(1, 2),

81 title="[bold]🏌️ Welcome to Golf 🏌️[/bold]",

82 title_align="center",

83 )

84

85 console.print(panel)

86

87

88 def create_command_header(title: str, subtitle: str = "", console: Console | None = None) -> None:

89 """Create a styled command header."""

90 if console is None:

91 console = Console()

92

93 header = Text()

94 header.append("🏌️ ", style=f"bold {GOLF_ORANGE}")

95 header.append(title, style=f"bold {GOLF_BLUE}")

96

97 if subtitle:

98 header.append(f" → {subtitle}", style=f"bold {GOLF_ORANGE}")

99

100 # Create a stylish panel for the header

101 panel = Panel(

102 Align.center(header),

103 border_style=GOLF_BLUE,

104 padding=(0, 2),

105 )

106

107 console.print(panel)

108

109

110 def create_success_message(message: str, console: Console | None = None) -> None:

111 """Create a styled success message."""

112 if console is None:

113 console = Console()

114

115 success_content = Text()

116 success_content.append("🎉 ", style=f"bold {GOLF_ORANGE}")

117 success_content.append(f"{STATUS_ICONS['success']} {message}", style=f"bold {GOLF_GREEN}")

118 success_content.append(" 🎉", style=f"bold {GOLF_ORANGE}")

119

120 success_panel = Panel(

121 Align.center(success_content),

122 border_style=GOLF_GREEN,

123 padding=(0, 2),

124 title="[bold green]SUCCESS[/bold green]",

125 title_align="center",

126 )

127 console.print(success_panel)

128

129

130 def create_info_panel(title: str, content: str, console: Console | None = None) -> None:

131 """Create a styled info panel."""

132 if console is None:

133 console = Console()

134

135 # Add some visual flair to the content

136 styled_content = Text()

137 for line in content.split("\n"):

138 if line.strip():

139 styled_content.append("▶ ", style=f"bold {GOLF_ORANGE}")

140 styled_content.append(line, style="bold white")

141 styled_content.append("\n")

142

143 panel = Panel(

144 styled_content,

145 title=f"[bold {GOLF_BLUE}]🔧 {title} 🔧[/bold {GOLF_BLUE}]",

146 border_style=GOLF_BLUE,

147 padding=(1, 2),

148 )

149 console.print(panel)

150

151

152 def get_status_text(status: str, message: str, style: str = "") -> Text:

153 """Get formatted status text with icon."""

154 icon = STATUS_ICONS.get(status, "•")

155 text = Text()

156

157 if status == "success":

158 text.append("🎉 ", style=f"bold {GOLF_ORANGE}")

159 text.append(f"{icon} {message}", style=f"bold {GOLF_GREEN}")

160 elif status == "error":

161 text.append("💥 ", style=f"bold {GOLF_ORANGE}")

162 text.append(f"{icon} {message}", style="bold red")

163 elif status == "warning":

164 text.append("⚡ ", style=f"bold {GOLF_ORANGE}")

165 text.append(f"{icon} {message}", style=f"bold {GOLF_ORANGE}")

166 elif status in ["building", "generating", "packaging", "platform"]:

167 text.append("🔥 ", style=f"bold {GOLF_ORANGE}")

168 text.append(f"{icon} {message}", style=f"bold {GOLF_BLUE}")

169 else:

170 text.append("💡 ", style=f"bold {GOLF_ORANGE}")

171 text.append(f"{icon} {message}", style=f"bold {GOLF_BLUE}")

172

173 return text

174

175

176 def create_build_header(project_name: str, environment: str, console: Console) -> None:

177 """Create a styled build process header."""

178 title = Text()

179 title.append("🔨 Building ", style=f"bold {GOLF_ORANGE}")

180 title.append(project_name, style=f"bold {GOLF_BLUE}")

181 title.append(f" ({environment} environment)", style=f"bold {GOLF_GREEN}")

182

183 # Create a flashy build panel

184 panel = Panel(

185 Align.center(title),

186 border_style=GOLF_ORANGE,

187 padding=(0, 2),

188 title="[bold]🚧 BUILD IN PROGRESS 🚧[/bold]",

189 title_align="center",

190 )

191

192 console.print(panel)