Coverage for little_loops / config / cli.py: 89%
54 statements
« prev ^ index » next coverage.py v7.12.0, created at 2026-03-18 16:20 -0500
« prev ^ index » next coverage.py v7.12.0, created at 2026-03-18 16:20 -0500
1"""CLI presentation configuration dataclasses.
3Covers ANSI color overrides for log levels, priority labels, type labels,
4and general CLI display options.
5"""
7from __future__ import annotations
9from dataclasses import dataclass, field
10from typing import Any
13@dataclass
14class CliColorsLoggerConfig:
15 """ANSI color overrides for Logger log-level output."""
17 info: str = "36"
18 success: str = "32"
19 warning: str = "33"
20 error: str = "38;5;208"
22 @classmethod
23 def from_dict(cls, data: dict[str, Any]) -> CliColorsLoggerConfig:
24 """Create CliColorsLoggerConfig from dictionary."""
25 return cls(
26 info=data.get("info", "36"),
27 success=data.get("success", "32"),
28 warning=data.get("warning", "33"),
29 error=data.get("error", "38;5;208"),
30 )
33@dataclass
34class CliColorsPriorityConfig:
35 """ANSI color overrides for issue priority labels (P0–P5)."""
37 P0: str = "38;5;208;1"
38 P1: str = "38;5;208"
39 P2: str = "33"
40 P3: str = "0"
41 P4: str = "2"
42 P5: str = "2"
44 @classmethod
45 def from_dict(cls, data: dict[str, Any]) -> CliColorsPriorityConfig:
46 """Create CliColorsPriorityConfig from dictionary."""
47 return cls(
48 P0=data.get("P0", "38;5;208;1"),
49 P1=data.get("P1", "38;5;208"),
50 P2=data.get("P2", "33"),
51 P3=data.get("P3", "0"),
52 P4=data.get("P4", "2"),
53 P5=data.get("P5", "2"),
54 )
57@dataclass
58class CliColorsTypeConfig:
59 """ANSI color overrides for issue type labels (BUG, FEAT, ENH)."""
61 BUG: str = "38;5;208"
62 FEAT: str = "32"
63 ENH: str = "34"
65 @classmethod
66 def from_dict(cls, data: dict[str, Any]) -> CliColorsTypeConfig:
67 """Create CliColorsTypeConfig from dictionary."""
68 return cls(
69 BUG=data.get("BUG", "38;5;208"),
70 FEAT=data.get("FEAT", "32"),
71 ENH=data.get("ENH", "34"),
72 )
75@dataclass
76class CliColorsConfig:
77 """ANSI color overrides for logger levels, priority labels, and type labels."""
79 logger: CliColorsLoggerConfig = field(default_factory=CliColorsLoggerConfig)
80 priority: CliColorsPriorityConfig = field(default_factory=CliColorsPriorityConfig)
81 type: CliColorsTypeConfig = field(default_factory=CliColorsTypeConfig)
82 fsm_active_state: str = "32"
84 @classmethod
85 def from_dict(cls, data: dict[str, Any]) -> CliColorsConfig:
86 """Create CliColorsConfig from dictionary."""
87 return cls(
88 logger=CliColorsLoggerConfig.from_dict(data.get("logger", {})),
89 priority=CliColorsPriorityConfig.from_dict(data.get("priority", {})),
90 type=CliColorsTypeConfig.from_dict(data.get("type", {})),
91 fsm_active_state=data.get("fsm_active_state", "32"),
92 )
95@dataclass
96class RefineStatusConfig:
97 """refine-status display configuration."""
99 columns: list[str] = field(default_factory=list)
100 elide_order: list[str] = field(default_factory=list)
102 @classmethod
103 def from_dict(cls, data: dict[str, Any]) -> RefineStatusConfig:
104 """Create RefineStatusConfig from dictionary."""
105 return cls(
106 columns=data.get("columns", []),
107 elide_order=data.get("elide_order", []),
108 )
111@dataclass
112class CliConfig:
113 """CLI output configuration."""
115 color: bool = True
116 colors: CliColorsConfig = field(default_factory=CliColorsConfig)
118 @classmethod
119 def from_dict(cls, data: dict[str, Any]) -> CliConfig:
120 """Create CliConfig from dictionary."""
121 return cls(
122 color=data.get("color", True),
123 colors=CliColorsConfig.from_dict(data.get("colors", {})),
124 )