Coverage for /Users/les/Projects/crackerjack/crackerjack/models/config_adapter.py: 0%
112 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-03 15:39 -0700
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-03 15:39 -0700
1import typing as t
3from .config import (
4 AIConfig,
5 CleaningConfig,
6 EnterpriseConfig,
7 ExecutionConfig,
8 GitConfig,
9 HookConfig,
10 ProgressConfig,
11 PublishConfig,
12 TestConfig,
13 WorkflowOptions,
14)
15from .protocols import OptionsProtocol
18class OptionsAdapter:
19 @staticmethod
20 def from_options_protocol(options: OptionsProtocol) -> WorkflowOptions:
21 return WorkflowOptions(
22 cleaning=CleaningConfig(
23 clean=getattr(options, "clean", True),
24 update_docs=getattr(options, "update_docs", False),
25 force_update_docs=getattr(options, "force_update_docs", False),
26 compress_docs=getattr(options, "compress_docs", False),
27 auto_compress_docs=getattr(options, "auto_compress_docs", False),
28 ),
29 hooks=HookConfig(
30 skip_hooks=getattr(options, "skip_hooks", False),
31 update_precommit=getattr(options, "update_precommit", False),
32 experimental_hooks=getattr(options, "experimental_hooks", False),
33 enable_pyrefly=getattr(options, "enable_pyrefly", False),
34 enable_ty=getattr(options, "enable_ty", False),
35 ),
36 testing=TestConfig(
37 test=getattr(options, "test", False),
38 benchmark=getattr(options, "benchmark", False),
39 test_workers=getattr(options, "test_workers", 0),
40 test_timeout=getattr(options, "test_timeout", 0),
41 ),
42 publishing=PublishConfig(
43 publish=getattr(options, "publish", None),
44 bump=getattr(options, "bump", None),
45 all=getattr(options, "all", None),
46 no_git_tags=getattr(options, "no_git_tags", False),
47 skip_version_check=getattr(options, "skip_version_check", False),
48 ),
49 git=GitConfig(
50 commit=getattr(options, "commit", False),
51 create_pr=getattr(options, "create_pr", False),
52 ),
53 ai=AIConfig(
54 ai_agent=getattr(options, "ai_agent", False),
55 autofix=getattr(options, "autofix", True),
56 ai_agent_autofix=getattr(options, "ai_agent_autofix", False),
57 start_mcp_server=getattr(options, "start_mcp_server", False),
58 max_iterations=getattr(options, "max_iterations", 10),
59 ),
60 execution=ExecutionConfig(
61 interactive=getattr(options, "interactive", False),
62 verbose=getattr(options, "verbose", False),
63 async_mode=getattr(options, "async_mode", False),
64 no_config_updates=getattr(options, "no_config_updates", False),
65 ),
66 progress=ProgressConfig(
67 enabled=getattr(options, "track_progress", False),
68 ),
69 enterprise=EnterpriseConfig(
70 enabled=getattr(options, "enterprise_batch", None) is not None,
71 license_key=getattr(options, "license_key", None),
72 organization=getattr(options, "organization", None),
73 ),
74 )
76 @staticmethod
77 def to_options_protocol(
78 workflow_options: WorkflowOptions,
79 ) -> "LegacyOptionsWrapper":
80 return LegacyOptionsWrapper(workflow_options)
83class LegacyOptionsWrapper:
84 def __init__(self, workflow_options: WorkflowOptions) -> None:
85 self._options = workflow_options
87 @property
88 def commit(self) -> bool:
89 return self._options.git.commit
91 @property
92 def interactive(self) -> bool:
93 return self._options.execution.interactive
95 @property
96 def no_config_updates(self) -> bool:
97 return self._options.execution.no_config_updates
99 @property
100 def verbose(self) -> bool:
101 return self._options.execution.verbose
103 @property
104 def update_docs(self) -> bool:
105 return self._options.cleaning.update_docs
107 @property
108 def force_update_docs(self) -> bool:
109 return self._options.cleaning.force_update_docs
111 @property
112 def compress_docs(self) -> bool:
113 return self._options.cleaning.compress_docs
115 @property
116 def auto_compress_docs(self) -> bool:
117 return self._options.cleaning.auto_compress_docs
119 @property
120 def clean(self) -> bool:
121 return self._options.cleaning.clean
123 @property
124 def test(self) -> bool:
125 return self._options.testing.test
127 @property
128 def benchmark(self) -> bool:
129 return self._options.testing.benchmark
131 @property
132 def test_workers(self) -> int:
133 return self._options.testing.test_workers
135 @property
136 def test_timeout(self) -> int:
137 return self._options.testing.test_timeout
139 @property
140 def publish(self) -> t.Any | None:
141 return self._options.publishing.publish
143 @property
144 def bump(self) -> t.Any | None:
145 return self._options.publishing.bump
147 @property
148 def all(self) -> t.Any | None:
149 return self._options.publishing.all
151 @property
152 def ai_agent(self) -> bool:
153 return self._options.ai.ai_agent
155 @property
156 def autofix(self) -> bool:
157 return self._options.ai.autofix
159 @property
160 def ai_agent_autofix(self) -> bool:
161 return self._options.ai.ai_agent_autofix
163 @property
164 def start_mcp_server(self) -> bool:
165 return self._options.ai.start_mcp_server
167 @property
168 def max_iterations(self) -> int:
169 return self._options.ai.max_iterations
171 @property
172 def create_pr(self) -> bool:
173 return self._options.git.create_pr
175 @property
176 def skip_hooks(self) -> bool:
177 return self._options.hooks.skip_hooks
179 @property
180 def update_precommit(self) -> bool:
181 return self._options.hooks.update_precommit
183 @property
184 def async_mode(self) -> bool:
185 return self._options.execution.async_mode
187 @property
188 def track_progress(self) -> bool:
189 return self._options.progress.enabled
191 @property
192 def experimental_hooks(self) -> bool:
193 return self._options.hooks.experimental_hooks
195 @property
196 def enable_pyrefly(self) -> bool:
197 return self._options.hooks.enable_pyrefly
199 @property
200 def enable_ty(self) -> bool:
201 return self._options.hooks.enable_ty
203 @property
204 def no_git_tags(self) -> bool:
205 return self._options.publishing.no_git_tags
207 @property
208 def skip_version_check(self) -> bool:
209 return self._options.publishing.skip_version_check
211 @property
212 def enterprise_batch(self) -> str | None:
213 return None
215 @property
216 def monitor_dashboard(self) -> str | None:
217 return None