11from rich .console import Console
22from rich .panel import Panel
3- from rich .table import Table
43from rich .progress import Progress , BarColumn , TextColumn
54from rich import box
6- from rich .text import Text
75from rich .columns import Columns
86import typer
97
@@ -37,7 +35,6 @@ def display_problem_not_found_error(problem):
3735
3836def display_submission_details (problem , problem_name , lang , file ):
3937 """Display submission details and confirmation prompt using a clean layout"""
40- # Create formatted text lines instead of a nested table
4138 content = [
4239 f"[cyan]Problem:[/] { problem } - { problem_name } " ,
4340 f"[cyan]Language:[/] { lang } " ,
@@ -71,7 +68,6 @@ def display_submission_results(result):
7168 if result ["success" ]:
7269 status = result ['status' ]
7370
74- # Set colors based on status
7571 if status == "Accepted" :
7672 status_style = "bold green"
7773 border_style = "green"
@@ -85,19 +81,27 @@ def display_submission_results(result):
8581 border_style = "red"
8682 emoji = "❌"
8783
88- # Get metrics
8984 runtime = result .get ('runtime' , 'N/A' )
9085 memory = result .get ('memory' , 'N/A' )
86+
87+ memory_warning = result .get ('memory_warning' )
88+ if memory_warning :
89+ memory = f"{ memory } [bold yellow](!)[/]"
90+
9191 passed = result .get ('passed_testcases' , 0 )
9292 total = result .get ('total_testcases' , 0 )
9393 test_case_str = f"{ passed } /{ total } ({ passed / total * 100 :.1f} %)" if total > 0 else "N/A"
9494
9595 content = [
9696 f"[cyan]⏱️ Runtime:[/] { runtime } " ,
97- f"[cyan]💾 Memory:[/] { memory } " ,
98- f"[cyan]🧪 Test Cases:[/] { test_case_str } "
97+ f"[cyan]💾 Memory:[/] { memory } "
9998 ]
10099
100+ if result .get ('elapsed_time' ):
101+ content .append (f"[cyan]⏲️ Elapsed Time:[/] { result .get ('elapsed_time' )} ms" )
102+
103+ content .append (f"[cyan]🧪 Test Cases:[/] { test_case_str } " )
104+
101105 title = f"{ emoji } Submission Result: [{ status_style } ]{ status } [/]"
102106 console .print (Panel (
103107 "\n " .join (content ),
@@ -106,9 +110,48 @@ def display_submission_results(result):
106110 box = box .ROUNDED
107111 ))
108112
109- if status != "Accepted" and result .get ('error_message' ):
110- error_msg = result .get ('error_message' , 'No details available' )
113+ if memory_warning :
114+ console .print (Panel (
115+ memory_warning ,
116+ title = "⚠️ Memory Usage Warning" ,
117+ border_style = "yellow" ,
118+ box = box .ROUNDED
119+ ))
120+
121+ if result .get ('stdout' ):
122+ console .print (Panel (
123+ result .get ('stdout' ),
124+ title = "📝 Standard Output" ,
125+ border_style = "blue" ,
126+ box = box .ROUNDED
127+ ))
128+
129+ if result .get ('output' ) and result .get ('expected' ):
130+ is_wrong_answer = status == "Wrong Answer"
131+
132+ output_panel = Panel (
133+ result .get ('output' , '' ),
134+ title = "Your Output" ,
135+ border_style = "red" if is_wrong_answer else "blue"
136+ )
137+ expected_panel = Panel (
138+ result .get ('expected' , '' ),
139+ title = "Expected Output" ,
140+ border_style = "green"
141+ )
142+ console .print (Columns ([output_panel , expected_panel ]))
143+
144+ if status != "Accepted" and result .get ('error' ):
145+ error_msg = result .get ('error' , 'No details available' )
111146 console .print (Panel (error_msg , title = "Error Details" , border_style = "red" ))
147+
148+ if result .get ('full_error' ):
149+ console .print (Panel (
150+ result .get ('full_error' , '' ),
151+ title = "Full Error Trace" ,
152+ border_style = "red" ,
153+ box = box .ROUNDED
154+ ))
112155 else :
113156 error_panel = Panel (
114157 f"{ result .get ('error' , 'Unknown error' )} " ,
@@ -117,6 +160,22 @@ def display_submission_results(result):
117160 )
118161 console .print (error_panel )
119162
163+ if result .get ('stdout' ):
164+ console .print (Panel (
165+ result .get ('stdout' ),
166+ title = "📝 Standard Output" ,
167+ border_style = "blue" ,
168+ box = box .ROUNDED
169+ ))
170+
171+ if result .get ('full_error' ):
172+ console .print (Panel (
173+ result .get ('full_error' , '' ),
174+ title = "Full Error Trace" ,
175+ border_style = "red" ,
176+ box = box .ROUNDED
177+ ))
178+
120179def display_exception_error (e ):
121180 """Display exception error message"""
122181 console .print (Panel (f"❌ Error: { str (e )} " , style = "bold red" , border_style = "red" ))
0 commit comments