Coverage for src/qdrant_loader/cli/commands/config_cmd.py: 0%
24 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-11 07:21 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-11 07:21 +0000
1from __future__ import annotations
3from pathlib import Path
5from click.exceptions import ClickException
6from click.utils import echo
8from qdrant_loader.cli.commands.config import run_show_config as _run_show_config
9from qdrant_loader.cli.config_loader import setup_workspace as _setup_workspace_impl
10from qdrant_loader.utils.logging import LoggingConfig
13def run_config_command(
14 workspace: Path | None, log_level: str, config: Path | None, env: Path | None
15) -> None:
16 """Implementation for the `config` CLI command."""
17 try:
18 # Maintain test expectation: log via workspace-logger as before
19 workspace_config = _setup_workspace_impl(workspace) if workspace else None
20 log_file = (
21 str(workspace_config.logs_path) if workspace_config else "qdrant-loader.log"
22 )
23 if getattr(LoggingConfig, "reconfigure", None): # type: ignore[attr-defined]
24 if getattr(LoggingConfig, "_initialized", False): # type: ignore[attr-defined]
25 LoggingConfig.reconfigure(file=log_file) # type: ignore[attr-defined]
26 else:
27 LoggingConfig.setup(level=log_level, format="console", file=log_file)
28 else:
29 import logging as _py_logging
31 _py_logging.getLogger().handlers = []
32 LoggingConfig.setup(level=log_level, format="console", file=log_file)
34 echo("Current Configuration:")
35 output = _run_show_config(workspace, config, env, log_level)
36 echo(output)
38 except Exception as e:
39 LoggingConfig.get_logger(__name__).error("config_failed", error=str(e))
40 raise ClickException(f"Failed to display configuration: {str(e)!s}") from e