22from rich import print
33
44import questionary
5+ from together .lib .cli .logger .config import CLIConfig
6+ from rich .theme import Theme
7+ from rich .console import Console
58
69custom_style_fancy = questionary .Style ([
710 ('qmark' , 'fg:#caaef5 bold' ), # token in front of the question
1619 ('disabled' , 'fg:#858585 italic' ) # disabled choices for select and checkbox prompts
1720])
1821
22+ custom_theme = Theme ({
23+ # Text styles
24+ "primary" : "#caaef5" , # Purple 300 ⭐ (lighter when bold)
25+ "secondary" : "dim #caaef5" , # Purple 500 ⭐ (mid-tone without bold)
26+ "accent" : "#ff68d4" , # Pink 500 ⭐
27+ "muted" : "#98a0b3" , # Grey 400 ⭐
28+ "dim" : "dim #626b84" , # Grey 600 ⭐
29+
30+ # Semantic styles
31+ "success" : "bold #0dce74" , # Green 400 ⭐
32+ "info" : "#64afff" , # Blue 500 ⭐
33+ "warning" : "bold #ff815d" , # Red 500 ⭐
34+ "error" : "bold #c63800" , # Red 700 ⭐
35+
36+ # UI elements
37+ "prompt" : "#ba92ff" , # Purple 500 ⭐ (no bold)
38+ "prompt.choices" : "#caaef5" , # Purple 300 ⭐
39+ "prompt.default" : "dim #98a0b3" , # Grey 400 ⭐
40+
41+ # Table styles
42+ "table.header" : "#414858" , # Purple 300 ⭐ (lighter when bold)
43+ "table.border" : "#626b84" , # Grey 600 ⭐
44+ "table.row" : "#c4c9d4" , # Grey 300 ⭐
45+
46+ # Progress/Loading
47+ "progress.description" : "#caaef5" , # Purple 300 ⭐
48+ "progress.percentage" : "bold #caaef5" , # Purple 300 ⭐ (lighter when bold)
49+ "bar.complete" : "#ba92ff" , # Purple 500 ⭐ (no bold)
50+ "bar.finished" : "#0dce74" , # Green 400 ⭐
51+ "bar.pulse" : "#ff68d4" , # Pink 500 ⭐
52+ })
53+
54+ console = Console (theme = custom_theme )
55+
56+
1957class NameValidator (questionary .Validator ):
2058 def validate (self , document ):
2159 if document .text .count (" " ) > 0 :
@@ -27,18 +65,21 @@ def validate(self, document):
2765class PromptParameter :
2866 message : str | None = None
2967 instructions : str | None = None
30- choices : list [str ] | None = None
68+ choices : list [str | questionary . Choice ] | None = None
3169
32- def __init__ (self , message : str | None = None , instructions : str | None = None , choices : list [str ] | None = None ):
70+ def __init__ (self , message : str | None = None , instructions : str | None = None , choices : list [str | questionary . Choice ] | None = None ):
3371 self .message = message
3472 self .instructions = instructions
3573 self .choices = choices
3674
75+ async def preprompt (self , _config : CLIConfig ):
76+ pass
77+
3778 async def prompt (self , field : str ) -> str :
3879 if self .instructions is not None :
3980 print (f"[dim]{ self .instructions } [/dim]" )
40-
81+
4182 if self .choices is not None :
42- return await questionary .select (self .message or field , choices = self .choices , style = custom_style_fancy ).unsafe_ask_async ()
83+ return await questionary .select (self .message or field , choices = self .choices , style = custom_style_fancy , show_selected = True ).unsafe_ask_async ()
4384
4485 return await questionary .text (self .message or field , instruction = "\n →" , style = custom_style_fancy , validate = NameValidator ).unsafe_ask_async ()
0 commit comments