Skip to content

Commit 4e36017

Browse files
committed
Allow the stting of solution providers from the application
1 parent 9d289bf commit 4e36017

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

cleo/application.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import sys
44

5+
from typing import TYPE_CHECKING
56
from typing import Dict
67
from typing import List
78
from typing import Optional
@@ -37,6 +38,12 @@
3738
from .ui.ui import UI
3839

3940

41+
if TYPE_CHECKING:
42+
from crashtest.solution_providers.solution_provider_repository import (
43+
SolutionProviderRepository,
44+
)
45+
46+
4047
class Application:
4148
"""
4249
An Application is the container for a collection of commands.
@@ -70,6 +77,10 @@ def __init__(self, name: str = "console", version: str = "") -> None:
7077

7178
self._command_loader: Optional[CommandLoader] = None
7279

80+
self._solution_provider_repository: Optional[
81+
"SolutionProviderRepository"
82+
] = None
83+
7384
@property
7485
def name(self) -> str:
7586
return self._name
@@ -160,6 +171,11 @@ def catch_exceptions(self, catch_exceptions: bool = True) -> None:
160171
def is_single_command(self) -> bool:
161172
return self._single_command
162173

174+
def set_solution_provider_repository(
175+
self, solution_provider_repository: "SolutionProviderRepository"
176+
) -> None:
177+
self._solution_provider_repository = solution_provider_repository
178+
163179
def add(self, command: Command) -> Optional[Command]:
164180
self._init()
165181

@@ -473,7 +489,9 @@ def create_io(
473489
def render_error(self, error: Exception, io: IO) -> None:
474490
from cleo.ui.exception_trace import ExceptionTrace
475491

476-
trace = ExceptionTrace(error)
492+
trace = ExceptionTrace(
493+
error, solution_provider_repository=self._solution_provider_repository
494+
)
477495
trace.render(io.error_output, isinstance(error, CleoSimpleException))
478496

479497
def _configure_io(self, io: IO) -> None:

cleo/ui/exception_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _render_solution(self, io: Union[IO, Output], inspector: Inspector):
316316
inspector.exception
317317
)
318318
symbol = "•"
319-
if not io.output.supports_utf8():
319+
if not io.supports_utf8():
320320
symbol = "*"
321321

322322
for solution in solutions:

0 commit comments

Comments
 (0)