4
4
from rich .panel import Panel
5
5
from rich .prompt import Confirm , Prompt
6
6
from rich .text import Text
7
- from rich .progress import Progress , SpinnerColumn , TextColumn , BarColumn , TaskProgressColumn
7
+ from rich .progress import (
8
+ Progress ,
9
+ SpinnerColumn ,
10
+ TextColumn ,
11
+ BarColumn ,
12
+ TaskProgressColumn ,
13
+ )
8
14
from typing import List , Optional
9
15
10
16
from ..core .analyzer import CommitAnalysis , WarningLevel
14
20
15
21
console = Console ()
16
22
23
+
17
24
def create_progress () -> Progress :
18
25
"""Create a progress bar with custom styling."""
19
26
return Progress (
@@ -24,12 +31,16 @@ def create_progress() -> Progress:
24
31
console = console ,
25
32
)
26
33
34
+
27
35
def print_changed_files (files : List [GitFile ]) -> None :
28
36
"""Print list of changed files."""
29
- console .print ("\n [bold blue]📜 Changes detected in the following files:[/bold blue]" )
37
+ console .print (
38
+ "\n [bold blue]📜 Changes detected in the following files:[/bold blue]"
39
+ )
30
40
for file in files :
31
41
console .print (f" - [cyan]{ file .path } [/cyan]" )
32
42
43
+
33
44
def print_warnings (analysis : CommitAnalysis ) -> None :
34
45
"""Print analysis warnings."""
35
46
if not analysis .warnings :
@@ -45,16 +56,23 @@ def print_warnings(analysis: CommitAnalysis) -> None:
45
56
console .print (f" • Estimated cost: €{ analysis .estimated_cost :.4f} " )
46
57
console .print (f" • Files changed: { analysis .num_files } " )
47
58
59
+
48
60
def print_batch_start (batch_num : int , total_batches : int , files : List [GitFile ]) -> None :
49
61
"""Print information about starting a new batch."""
50
- console .print (f"\n [bold blue]📦 Processing Batch { batch_num } /{ total_batches } [/bold blue]" )
62
+ console .print (
63
+ f"\n [bold blue]📦 Processing Batch { batch_num } /{ total_batches } [/bold blue]"
64
+ )
51
65
console .print ("[cyan]Files in this batch:[/cyan]" )
52
66
for file in files :
53
67
console .print (f" - [dim]{ file .path } [/dim]" )
54
68
69
+
55
70
def print_batch_complete (batch_num : int , total_batches : int ) -> None :
56
71
"""Print completion message for a batch."""
57
- console .print (f"\n [bold green]✅ Batch { batch_num } /{ total_batches } completed successfully[/bold green]" )
72
+ console .print (
73
+ f"\n [bold green]✅ Batch { batch_num } /{ total_batches } completed successfully[/bold green]"
74
+ )
75
+
58
76
59
77
def print_batch_summary (total_files : int , total_batches : int ) -> None :
60
78
"""Print summary of batch processing plan."""
@@ -63,12 +81,14 @@ def print_batch_summary(total_files: int, total_batches: int) -> None:
63
81
console .print (f" • Number of batches: [cyan]{ total_batches } [/cyan]" )
64
82
console .print (f" • Files per batch: [cyan]~{ total_files // total_batches } [/cyan]" )
65
83
84
+
66
85
def format_cost (cost : float ) -> str :
67
86
"""Format cost in both human-readable and precise formats."""
68
87
human_cost = CommitAnalyzer .format_cost_for_humans (cost )
69
88
precise_cost = f"(€{ cost :.8f} )"
70
89
return f"{ human_cost } { precise_cost } "
71
90
91
+
72
92
def print_token_usage (usage : TokenUsage , batch_num : Optional [int ] = None ) -> None :
73
93
"""Print token usage summary."""
74
94
batch_info = f" (Batch { batch_num } )" if batch_num is not None else ""
@@ -86,45 +106,54 @@ def print_token_usage(usage: TokenUsage, batch_num: Optional[int] = None) -> Non
86
106
"""
87
107
)
88
108
109
+
89
110
def print_commit_message (message : str ) -> None :
90
111
"""Print formatted commit message."""
91
112
console .print (Panel (Text (message ), expand = False , border_style = "green" ))
92
113
114
+
93
115
def print_batch_info (batch_number : int , files : List [str ]) -> None :
94
116
"""Print information about a batch of files."""
95
117
console .print (f"\n [bold blue]📑 Batch { batch_number } Summary:[/bold blue]" )
96
118
for file in files :
97
119
console .print (f" - [cyan]{ file } [/cyan]" )
98
120
121
+
99
122
def confirm_action (prompt : str ) -> bool :
100
123
"""Ask user to confirm an action."""
101
124
return Confirm .ask (f"\n { prompt } " )
102
125
126
+
103
127
def confirm_batch_continue () -> bool :
104
128
"""Ask user if they want to continue with next batch."""
105
129
return Confirm .ask ("\n [bold yellow]🤔 Continue with next batch?[/bold yellow]" )
106
130
131
+
107
132
def select_commit_strategy () -> str :
108
133
"""Ask user how they want to handle multiple commits."""
109
- console .print ("\n [bold blue]🤔 How would you like to handle the commits?[/bold blue]" )
134
+ console .print (
135
+ "\n [bold blue]🤔 How would you like to handle the commits?[/bold blue]"
136
+ )
110
137
return Prompt .ask (
111
- "Choose strategy" ,
112
- choices = ["individual" , "combined" ],
113
- default = "individual"
138
+ "Choose strategy" , choices = ["individual" , "combined" ], default = "individual"
114
139
)
115
140
141
+
116
142
def print_success (message : str ) -> None :
117
143
"""Print success message."""
118
144
console .print (f"\n [bold green]✅ { message } [/bold green]" )
119
145
146
+
120
147
def print_error (message : str ) -> None :
121
148
"""Print error message."""
122
149
console .print (f"\n [bold red]❌ { message } [/bold red]" )
123
150
151
+
124
152
def print_info (message : str ) -> None :
125
153
"""Print info message."""
126
154
console .print (f"\n [bold blue]ℹ️ { message } [/bold blue]" )
127
155
156
+
128
157
def print_warning (message : str ) -> None :
129
158
"""Print warning message."""
130
159
console .print (f"\n [bold yellow]⚠️ { message } [/bold yellow]" )
0 commit comments