|
7 | 7 | import xml.etree.ElementTree as ET |
8 | 8 | from dataclasses import dataclass |
9 | 9 | from enum import Enum, auto |
| 10 | +from functools import lru_cache |
10 | 11 | from pathlib import Path |
11 | 12 | from typing import Any, Union |
12 | 13 |
|
@@ -55,6 +56,7 @@ class JavaSetupInfo: |
55 | 56 | benchmarks_root: Union[str, None] = None |
56 | 57 |
|
57 | 58 |
|
| 59 | +@lru_cache(maxsize=1) |
58 | 60 | def _get_theme(): |
59 | 61 | """Get the CodeflashTheme - imported lazily to avoid circular imports.""" |
60 | 62 | from codeflash.cli_cmds.init_config import CodeflashTheme |
@@ -366,17 +368,15 @@ def _prompt_directory_override(dir_type: str, detected: str, curdir: Path) -> st |
366 | 368 |
|
367 | 369 | def _prompt_custom_directory(dir_type: str) -> str: |
368 | 370 | """Prompt for a custom directory path.""" |
| 371 | + # Reuse the question object to avoid reconstructing it on every loop iteration. |
| 372 | + custom_question = inquirer.Path( |
| 373 | + "custom_path", |
| 374 | + message=f"Enter the path to your {dir_type} directory", |
| 375 | + path_type=inquirer.Path.DIRECTORY, |
| 376 | + exists=True, |
| 377 | + ) |
369 | 378 | while True: |
370 | | - custom_questions = [ |
371 | | - inquirer.Path( |
372 | | - "custom_path", |
373 | | - message=f"Enter the path to your {dir_type} directory", |
374 | | - path_type=inquirer.Path.DIRECTORY, |
375 | | - exists=True, |
376 | | - ) |
377 | | - ] |
378 | | - |
379 | | - custom_answers = inquirer.prompt(custom_questions, theme=_get_theme()) |
| 379 | + custom_answers = inquirer.prompt([custom_question], theme=_get_theme()) |
380 | 380 | if not custom_answers: |
381 | 381 | apologize_and_exit() |
382 | 382 |
|
|
0 commit comments