Skip to content

Commit 250cffc

Browse files
author
tjazerzen
committed
Display dist/ folder on the TUI
1 parent fe00ada commit 250cffc

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

module_renderer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,10 @@ def render_module(self) -> None:
261261
_, _, rendering_failed = self._render_module(self.filename, self.render_range, True)
262262
if not rendering_failed:
263263
# Get the last module that completed rendering
264-
last_module_name = self.loaded_modules[-1].name if self.loaded_modules else ""
265-
self.event_bus.publish(RenderCompleted(module_name=last_module_name, build_folder=self.args.build_folder))
264+
if self.args.copy_build:
265+
rendered_code_path = f"{self.args.build_dest}/"
266+
else:
267+
last_module_name = self.filename.replace(plain_file.PLAIN_SOURCE_FILE_EXTENSION, "")
268+
rendered_code_path = f"{os.path.join(self.args.build_folder, last_module_name)}/"
269+
270+
self.event_bus.publish(RenderCompleted(rendered_code_path=rendered_code_path))

plain2code_events.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class RenderContextSnapshot:
2828
class RenderCompleted(BaseEvent):
2929
"""Event emitted when rendering completes successfully."""
3030

31-
module_name: str
32-
build_folder: str
31+
rendered_code_path: str
3332

3433

3534
@dataclass

tui/plain2code_tui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def _handle_frid_state(
274274

275275
def on_render_completed(self, event: RenderCompleted):
276276
"""Handle successful render completion."""
277-
self._render_success_handler.handle(event.module_name, event.build_folder)
277+
self._render_success_handler.handle(event.rendered_code_path)
278278

279279
def on_render_failed(self, event: RenderFailed):
280280
"""Handle render failure."""

tui/state_handlers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,13 @@ def __init__(self, tui):
299299
"""
300300
self.tui = tui
301301

302-
def handle(self, module_name: str, build_folder: str) -> None:
302+
def handle(self, rendered_code_path: str) -> None:
303303
"""Handle successful render completion.
304304
305305
Args:
306-
module_name: Name of the last module that completed rendering
307-
build_folder: The build folder path
306+
rendered_code_path: The path to the rendered code
308307
"""
309-
display_success_message(self.tui, module_name, build_folder)
308+
display_success_message(self.tui, rendered_code_path)
310309

311310

312311
class RenderErrorHandler:

tui/widget_helpers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Widget update helper utilities for Plain2Code TUI."""
22

3-
import os
43
from datetime import datetime
54

65
from textual.css.query import NoMatches
@@ -98,17 +97,15 @@ def get_frid_progress(tui) -> FRIDProgress:
9897
return tui.query_one(f"#{TUIComponents.FRID_PROGRESS.value}", FRIDProgress)
9998

10099

101-
def display_success_message(tui, module_name: str, build_folder: str):
100+
def display_success_message(tui, rendered_code_path: str):
102101
"""Display success message with code location and exit instructions.
103102
104103
Args:
105104
tui: The Plain2CodeTUI instance
106-
module_name: Name of the module that was rendered
107-
build_folder: The build folder path
105+
rendered_code_path: The path to the rendered code
108106
"""
109107

110-
code_location = os.path.join(build_folder, module_name)
111-
message = f"[#79FC96]✓ Rendering finished![/#79FC96] [#888888](ctrl+c to exit)[/#888888]\n[#888888]Generated code: {code_location}[/#888888] "
108+
message = f"[#79FC96]✓ Rendering finished![/#79FC96] [#888888](ctrl+c to exit)[/#888888]\n[#888888]Generated code: {rendered_code_path}[/#888888] "
112109

113110
widget: Static = tui.query_one(f"#{TUIComponents.RENDER_STATUS_WIDGET.value}", Static)
114111
widget.update(message)

0 commit comments

Comments
 (0)