Skip to content

Commit 69e0de3

Browse files
committed
themed
1 parent 290a294 commit 69e0de3

2 files changed

Lines changed: 113 additions & 1 deletion

File tree

codeflash/cli_cmds/cmd_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import git
1414
import tomlkit
1515
from git import InvalidGitRepositoryError, Repo
16-
from inquirer_textual import prompts # type: ignore[import-untyped]
1716
from inquirer_textual.common.Choice import Choice # type: ignore[import-untyped]
1817
from pydantic.dataclasses import dataclass
1918
from rich.console import Group
@@ -22,6 +21,7 @@
2221
from rich.text import Text
2322

2423
from codeflash.api.cfapi import get_user_id, is_github_app_installed_on_repo
24+
from codeflash.cli_cmds import themed_prompts as prompts
2525
from codeflash.cli_cmds.cli_common import apologize_and_exit
2626
from codeflash.cli_cmds.console import console, logger
2727
from codeflash.cli_cmds.extension import install_vscode_extension
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
"""Themed prompts wrapper for inquirer-textual with CodeFlash styling.
2+
3+
This module provides themed prompt functions that match the original CodeFlash
4+
inquirer theme (yellow question marks, bright blue selections, cyan defaults).
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from inquirer_textual.common.Choice import Choice # type: ignore[import-untyped]
10+
from inquirer_textual.common.Result import Result # type: ignore[import-untyped]
11+
from inquirer_textual.InquirerApp import InquirerApp # type: ignore[import-untyped]
12+
from inquirer_textual.widgets.InquirerCheckbox import InquirerCheckbox # type: ignore[import-untyped]
13+
from inquirer_textual.widgets.InquirerConfirm import InquirerConfirm # type: ignore[import-untyped]
14+
from inquirer_textual.widgets.InquirerSelect import InquirerSelect # type: ignore[import-untyped]
15+
from inquirer_textual.widgets.InquirerText import InquirerText # type: ignore[import-untyped]
16+
17+
18+
class CodeflashThemedApp(InquirerApp): # type: ignore[misc]
19+
"""Custom themed InquirerApp matching the original CodeFlash theme colors."""
20+
21+
def get_theme_variable_defaults(self) -> dict[str, str]:
22+
"""Return CodeFlash theme colors.
23+
24+
Original CodeFlash theme from inquirer:
25+
- Question mark: yellow
26+
- Brackets: bright blue
27+
- Default: bright cyan
28+
- Selection: bright blue
29+
- Checkbox selected: ✅
30+
- Checkbox unselected: ⬜
31+
"""
32+
return {
33+
# Question mark color - yellow like the original
34+
"select-question-mark": "#e5c07b", # Gold/yellow
35+
# List item highlight - bright blue like the original selection
36+
"select-list-item-highlight-foreground": "#61afef", # Bright blue
37+
# Input/text color - cyan like the original
38+
"input-color": "#61afef", # Bright blue (used for inputs and selections)
39+
# Additional contrast colors
40+
"input-selection-background": "#3e4451", # Subtle background for selected items
41+
}
42+
43+
44+
def select(
45+
message: str, choices: list[str | Choice], default: str | Choice | None = None, mandatory: bool = True
46+
) -> Result[str | Choice]: # type: ignore[type-arg]
47+
"""Display a select prompt with CodeFlash theming.
48+
49+
Args:
50+
message: The prompt message to display
51+
choices: List of choices (strings or Choice objects)
52+
default: Default choice to pre-select
53+
mandatory: Whether a response is mandatory
54+
55+
Returns:
56+
Result object containing the selected value and command
57+
58+
"""
59+
widget = InquirerSelect(message, choices, default, mandatory)
60+
app: CodeflashThemedApp = CodeflashThemedApp(widget, shortcuts=None, show_footer=False) # type: ignore[assignment]
61+
return app.run(inline=True) # type: ignore[return-value]
62+
63+
64+
def confirm(message: str, default: bool = False, mandatory: bool = True) -> Result[bool]: # type: ignore[type-arg]
65+
"""Display a confirm prompt with CodeFlash theming.
66+
67+
Args:
68+
message: The prompt message to display
69+
default: Default value (True for yes, False for no)
70+
mandatory: Whether a response is mandatory
71+
72+
Returns:
73+
Result object containing the boolean value and command
74+
75+
"""
76+
widget = InquirerConfirm(message, default=default, mandatory=mandatory)
77+
app: CodeflashThemedApp = CodeflashThemedApp(widget, shortcuts=None, show_footer=False) # type: ignore[assignment]
78+
return app.run(inline=True) # type: ignore[return-value]
79+
80+
81+
def text(message: str) -> Result[str]: # type: ignore[type-arg]
82+
"""Display a text input prompt with CodeFlash theming.
83+
84+
Args:
85+
message: The prompt message to display
86+
87+
Returns:
88+
Result object containing the text value and command
89+
90+
"""
91+
widget = InquirerText(message)
92+
app: CodeflashThemedApp = CodeflashThemedApp(widget, shortcuts=None, show_footer=False) # type: ignore[assignment]
93+
return app.run(inline=True) # type: ignore[return-value]
94+
95+
96+
def checkbox(
97+
message: str, choices: list[str | Choice], enabled: list[str | Choice] | None = None
98+
) -> Result[list[str | Choice]]: # type: ignore[type-arg]
99+
"""Display a checkbox prompt with CodeFlash theming.
100+
101+
Args:
102+
message: The prompt message to display
103+
choices: List of choices (strings or Choice objects)
104+
enabled: List of pre-selected choices
105+
106+
Returns:
107+
Result object containing the list of selected values and command
108+
109+
"""
110+
widget = InquirerCheckbox(message, choices, enabled)
111+
app: CodeflashThemedApp = CodeflashThemedApp(widget, shortcuts=None, show_footer=False) # type: ignore[assignment]
112+
return app.run(inline=True) # type: ignore[return-value]

0 commit comments

Comments
 (0)