55from .internal import version_info
66from collections .abc import Sequence
77from contextlib import contextmanager
8+ from cookieplone import __version__ as cookieplone_version
89from cookieplone import _types as t
910from cookieplone .settings import QUIET_MODE_VAR
1011from pathlib import Path
1718from rich .table import Table
1819from rich .text import Text
1920from textwrap import dedent
21+ from typing import Any
2022
2123import os
2224
@@ -95,39 +97,44 @@ def print(msg: str, style: str = "", color: str = ""): # noQA:A001
9597 _print (f"{ tag_open } { escape (msg )} { tag_close } " )
9698
9799
98- def print_plone_banner ():
100+ def print_plone_banner () -> None :
99101 """Print Plone banner."""
100102 style : str = "bold"
101103 color : str = "blue"
102104 banner = choose_banner ()
103105 print (banner , style , color )
104106
105107
106- def info (msg : str ):
108+ def info (msg : str ) -> None :
109+ """Print an informational message in bold white."""
107110 style : str = "bold"
108111 color : str = "white"
109112 print (msg , style , color )
110113
111114
112- def success (msg : str ):
115+ def success (msg : str ) -> None :
116+ """Print a success message in bold green."""
113117 style : str = "bold"
114118 color : str = "green"
115119 print (msg , style , color )
116120
117121
118- def error (msg : str ):
122+ def error (msg : str ) -> None :
123+ """Print an error message in bold red."""
119124 style : str = "bold"
120125 color : str = "red"
121126 print (msg , style , color )
122127
123128
124- def warning (msg : str ):
129+ def warning (msg : str ) -> None :
130+ """Print a warning message in bold yellow."""
125131 style : str = "bold"
126132 color : str = "yellow"
127133 print (msg , style , color )
128134
129135
130- def panel (title : str , msg : str = "" , subtitle : str = "" , url : str = "" ):
136+ def panel (title : str , msg : str = "" , subtitle : str = "" , url : str = "" ) -> None :
137+ """Print a Rich panel with an optional subtitle and clickable URL."""
131138 msg = dedent (msg )
132139 if url :
133140 msg = f"{ msg } \n [link]{ url } [/link]"
@@ -143,9 +150,16 @@ def panel(title: str, msg: str = "", subtitle: str = "", url: str = ""):
143150def create_table (
144151 columns : list [dict ] | None = None ,
145152 rows : Sequence [Sequence [str ]] | None = None ,
146- ** kwargs ,
153+ ** kwargs : Any ,
147154) -> Table :
148- """Create table."""
155+ """Create a Rich :class:`~rich.table.Table` from column definitions and row data.
156+
157+ :param columns: List of dicts, each containing a ``title`` key and any
158+ extra keyword arguments accepted by :meth:`~rich.table.Table.add_column`.
159+ :param rows: Sequence of row tuples passed to :meth:`~rich.table.Table.add_row`.
160+ :param kwargs: Forwarded to the :class:`~rich.table.Table` constructor.
161+ :returns: A fully populated :class:`~rich.table.Table`.
162+ """
149163 table = Table (** kwargs )
150164 for column in columns :
151165 col_title = column .pop ("title" , "" )
@@ -188,7 +202,19 @@ def list_available_groups(
188202def welcome_screen (
189203 templates : dict [str , t .CookieploneTemplate ] | None = None ,
190204 groups : dict [str , t .CookieploneTemplateGroup ] | None = None ,
191- ):
205+ ) -> None :
206+ """Display the Cookieplone welcome screen with an optional template or group list.
207+
208+ Clears the terminal, renders the Plone banner, and — when provided —
209+ appends a panel listing either template *groups* (category selection)
210+ or individual *templates* (template selection).
211+
212+ :param templates: Templates to list. Mutually exclusive with *groups*.
213+ :param groups: Template groups to list. Takes precedence over *templates*.
214+ """
215+ # Always clear the screen, even if we're not printing the banner,
216+ # to ensure a clean start.
217+ clear_screen ()
192218 banner = choose_banner ()
193219 items = [
194220 Align .center (f"[bold blue]{ banner } [/bold blue]" ),
@@ -205,19 +231,26 @@ def welcome_screen(
205231 title_align = "left" ,
206232 )
207233 )
234+ panel_title = f"cookieplone ({ cookieplone_version } )"
208235 panel = Panel (
209236 Group (* items ),
210- title = "cookieplone" ,
237+ title = panel_title ,
211238 )
212239 base_print (panel )
213240
214241
215- def version_screen ():
242+ def version_screen () -> None :
216243 """Print version information."""
217244 base_print (version_info ())
218245
219246
220- def info_screen (repository : str | Path , passwd : str , tag : str ):
247+ def info_screen (repository : str | Path , passwd : str , tag : str ) -> None :
248+ """Print a detailed information panel about the current Cookieplone installation.
249+
250+ :param repository: Template repository URL or local path.
251+ :param passwd: Repository password (may be empty).
252+ :param tag: Git tag or branch used for the repository.
253+ """
221254 info = cookieplone_info (repository , passwd , tag )
222255 title = info ["title" ]
223256 subtitle = info ["subtitle" ]
0 commit comments