Coverage for src / ezpl / cli / commands / info.py: 81.82%
73 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-13 19:35 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-13 19:35 +0000
1# ///////////////////////////////////////////////////////////////
2# EZPL - CLI Info Command
3# Project: ezpl
4# ///////////////////////////////////////////////////////////////
6"""
7CLI command for displaying package information.
9This module provides the info command for Ezpl.
10"""
12from __future__ import annotations
14# ///////////////////////////////////////////////////////////////
15# IMPORTS
16# ///////////////////////////////////////////////////////////////
17# Standard library imports
18from importlib.metadata import PackageNotFoundError, version
19from pathlib import Path
21import click
23# Third-party imports
24from rich.panel import Panel
25from rich.table import Table
26from rich.text import Text
28# Local imports
29import ezpl
31from ...config import ConfigurationManager
32from .._console import console
34# ///////////////////////////////////////////////////////////////
35# COMMANDS
36# ///////////////////////////////////////////////////////////////
39@click.command(name="info", help="Display package information")
40def info_command() -> None:
41 """
42 Display package information.
44 Show detailed information about the Ezpl package including
45 version, location, configuration, and dependencies.
46 """
47 try:
48 # Package info
49 ezpl_version = getattr(ezpl, "__version__", "unknown")
50 author = getattr(ezpl, "__author__", "unknown")
51 maintainer = getattr(ezpl, "__maintainer__", "unknown")
52 license_type = getattr(ezpl, "__license__", "unknown")
53 description = getattr(ezpl, "__description__", "unknown")
54 url = getattr(ezpl, "__url__", "unknown")
56 # Package location
57 try:
58 package_path = (
59 Path(ezpl.__file__).parent if hasattr(ezpl, "__file__") else None
60 )
61 except (AttributeError, TypeError, OSError):
62 package_path = None
64 # Configuration info
65 config_manager = ConfigurationManager()
66 config_file = config_manager.config_file
67 log_file = config_manager.get_log_file()
69 # Build info text
70 text = Text()
71 text.append("Package Information\n", style="bold bright_blue")
72 text.append("=" * 50 + "\n\n", style="dim")
74 # Version
75 text.append("Version: ", style="bold")
76 text.append(f"{ezpl_version}\n", style="white")
78 # Author
79 text.append("Author: ", style="bold")
80 text.append(f"{author}\n", style="white")
82 if maintainer != author: 82 ↛ 83line 82 didn't jump to line 83 because the condition on line 82 was never true
83 text.append("Maintainer: ", style="bold")
84 text.append(f"{maintainer}\n", style="white")
86 # License
87 text.append("License: ", style="bold")
88 text.append(f"{license_type}\n", style="white")
90 # Description
91 text.append("\nDescription:\n", style="bold")
92 text.append(f" {description}\n", style="dim white")
94 # URL
95 text.append("\nURL: ", style="bold")
96 text.append(f"{url}\n", style="cyan")
98 # Package location
99 if package_path: 99 ↛ 104line 99 didn't jump to line 104 because the condition on line 99 was always true
100 text.append("\nPackage Location: ", style="bold")
101 text.append(f"{package_path}\n", style="dim white")
103 # Configuration paths
104 text.append("\nConfiguration:\n", style="bold")
105 text.append(" Config File: ", style="dim")
106 text.append(f"{config_file}\n", style="white")
107 text.append(" Log File: ", style="dim")
108 text.append(f"{log_file}\n", style="white")
110 # Display panel
111 panel = Panel(
112 text,
113 title="[bold bright_blue]Ezpl Information[/bold bright_blue]",
114 border_style="bright_blue",
115 padding=(1, 2),
116 )
117 console.print(panel)
119 # Dependencies table
120 try:
121 import loguru
122 import rich
124 try:
125 click_version = version("click")
126 except PackageNotFoundError:
127 click_version = "unknown"
129 deps_table = Table(
130 title="Dependencies", show_header=True, header_style="bold blue"
131 )
132 deps_table.add_column("Package", style="cyan")
133 deps_table.add_column("Version", style="green")
135 deps_table.add_row("loguru", getattr(loguru, "__version__", "unknown"))
136 deps_table.add_row("rich", getattr(rich, "__version__", "unknown"))
137 deps_table.add_row("click", click_version)
139 console.print("\n")
140 console.print(deps_table)
141 except (ImportError, OSError, RuntimeError, ValueError) as e:
142 console.print(f"[bold red]Error:[/bold red] {e}")
144 except click.ClickException:
145 raise
146 except (OSError, RuntimeError, ValueError, TypeError, AttributeError) as e:
147 raise click.ClickException(str(e)) from e