Config command module for CCProxy API.
config_list
Show current configuration.
Source code in ccproxy/cli/commands/config/commands.py
| @app.command(name="list")
def config_list() -> None:
"""Show current configuration."""
toolkit = get_rich_toolkit()
try:
settings = get_settings(config_path=get_config_path_from_context())
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
console = Console()
# Generate configuration rows dynamically from the Settings model
all_rows = _generate_config_rows_from_model(settings)
# Add computed fields that aren't part of the model but are useful to display
all_rows.append(
("server_url", settings.server_url, "Complete server URL (computed)")
)
# Group rows by configuration section
grouped_rows = _group_config_rows(all_rows)
# Display header
console.print(
Panel.fit(
f"[bold]CCProxy API Configuration[/bold]\n[dim]Version: {__version__}[/dim]",
border_style="blue",
)
)
console.print()
# Display each configuration section as a table
for section_name, section_rows in grouped_rows.items():
if section_rows: # Only show sections that have data
table = _create_config_table(section_name, section_rows)
console.print(table)
console.print()
# Show configuration file sources
info_text = Text()
info_text.append("Configuration loaded from: ", style="bold")
info_text.append(
"environment variables, .env file, and TOML configuration files",
style="dim",
)
console.print(
Panel(info_text, title="Configuration Sources", border_style="green")
)
except Exception as e:
toolkit.print(f"Error loading configuration: {e}", tag="error")
raise typer.Exit(1) from e
|