1- use std:: env;
2- use std:: fmt:: Write as FmtWrite ;
3- use std:: fs;
4- use std:: io;
1+ use std:: { env, fmt:: Write as FmtWrite , fs, io} ;
52
3+ use crossterm:: {
4+ event:: { self , Event , KeyCode , KeyEventKind } ,
5+ terminal:: { disable_raw_mode, enable_raw_mode} ,
6+ } ;
7+ use ratatui:: {
8+ layout:: { Alignment , Constraint , Direction , Layout , Rect } ,
9+ prelude:: * ,
10+ style:: { Color , Modifier , Style , Stylize } ,
11+ widgets:: { Block , Borders , List , ListItem , Paragraph , StatefulWidget , Widget } ,
12+ } ;
13+ use strum:: { Display , EnumIter , FromRepr , IntoEnumIterator } ;
14+ use tui_nodes:: { Connection , LineType , NodeGraph , NodeLayout } ;
615use wrt_component:: component:: {
716 AliasInfo , Component , ComponentSummary , CoreInstanceInfo , CoreModuleInfo , ExtendedExportInfo ,
817 ExtendedImportInfo , ModuleExportInfo , ModuleImportInfo ,
918} ;
1019use wrt_decoder:: ProducersSection ;
1120use wrt_error:: { Error , Result } ;
12-
13- use crossterm:: event:: { self , Event , KeyCode , KeyEventKind } ;
14- use crossterm:: terminal:: { disable_raw_mode, enable_raw_mode} ;
15- use ratatui:: layout:: { Alignment , Constraint , Direction , Layout , Rect } ;
16- use ratatui:: prelude:: * ;
17- use ratatui:: style:: { Color , Modifier , Style , Stylize } ;
18- use ratatui:: widgets:: { Block , Borders , List , ListItem , Paragraph , StatefulWidget , Widget } ;
19- use strum:: { Display , EnumIter , FromRepr , IntoEnumIterator } ;
20- use tui_nodes:: { Connection , LineType , NodeGraph , NodeLayout } ;
2121use wrt_format:: module:: ImportDesc ;
2222
2323/// Main state struct for the application
@@ -760,7 +760,8 @@ impl App {
760760 graph
761761 }
762762
763- /// Build the details graph showing detailed information about a specific entity
763+ /// Build the details graph showing detailed information about a specific
764+ /// entity
764765 fn build_details_graph ( & self , width : u16 , height : u16 ) -> NodeGraph < ' static > {
765766 let mut nodes = Vec :: new ( ) ;
766767 let mut connections = Vec :: new ( ) ;
@@ -948,7 +949,8 @@ impl App {
948949
949950 // Create detailed debug content
950951 let component_info = format ! (
951- "Component file size: {}\n Modules: {}\n Instances: {}\n Imports: {}\n Exports: {}\n Aliases: {}" ,
952+ "Component file size: {}\n Modules: {}\n Instances: {}\n Imports: {}\n Exports: \
953+ {}\n Aliases: {}",
952954 self . component_bytes. as_ref( ) . map_or( 0 , |b| b. len( ) ) ,
953955 self . component_summary. core_modules_count,
954956 self . component_summary. core_instances_count,
@@ -1113,7 +1115,8 @@ impl App {
11131115 % if self . debug_mode {
11141116 SelectedView :: iter ( ) . count ( )
11151117 } else {
1116- SelectedView :: iter ( ) . count ( ) - 1 // Skip Debug view when not in debug mode
1118+ SelectedView :: iter ( ) . count ( ) - 1 // Skip Debug view when
1119+ // not in debug mode
11171120 } ;
11181121 self . selected_view =
11191122 SelectedView :: from_repr ( next_idx) . unwrap_or ( self . selected_view ) ;
@@ -1123,7 +1126,8 @@ impl App {
11231126 let max_idx = if self . debug_mode {
11241127 SelectedView :: iter ( ) . count ( )
11251128 } else {
1126- SelectedView :: iter ( ) . count ( ) - 1 // Skip Debug view when not in debug mode
1129+ SelectedView :: iter ( ) . count ( ) - 1 // Skip Debug view when not
1130+ // in debug mode
11271131 } ;
11281132 let prev_idx = if current_idx == 0 { max_idx - 1 } else { current_idx - 1 } ;
11291133 self . selected_view =
@@ -1257,20 +1261,28 @@ impl App {
12571261
12581262 // Render status bar
12591263 let mut status_text = match self . selected_view {
1260- SelectedView :: Overview =>
1261- "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode | q: Quit" . to_string ( ) ,
1262- SelectedView :: Modules =>
1263- "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode | ↑↓: Select Module | Enter: Details | q: Quit" . to_string ( ) ,
1264- SelectedView :: Imports =>
1265- "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode | ↑↓: Select Import | Enter: Details | q: Quit" . to_string ( ) ,
1266- SelectedView :: Exports =>
1267- "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode | ↑↓: Select Export | Enter: Details | q: Quit" . to_string ( ) ,
1268- SelectedView :: Producers =>
1269- "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode | ↑↓: Select Producer | Enter: View Producer Details (Languages, Tools, SDKs) | q: Quit" . to_string ( ) ,
1270- SelectedView :: Details =>
1271- "1-6: Switch Views | Tab/←→: Navigate Views | q: Quit" . to_string ( ) ,
1272- SelectedView :: Debug =>
1273- "1-7: Switch Views | Tab/←→: Navigate Views | q: Quit" . to_string ( ) ,
1264+ SelectedView :: Overview => {
1265+ "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode | q: Quit" . to_string ( )
1266+ }
1267+ SelectedView :: Modules => "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode \
1268+ | ↑↓: Select Module | Enter: Details | q: Quit"
1269+ . to_string ( ) ,
1270+ SelectedView :: Imports => "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode \
1271+ | ↑↓: Select Import | Enter: Details | q: Quit"
1272+ . to_string ( ) ,
1273+ SelectedView :: Exports => "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus Mode \
1274+ | ↑↓: Select Export | Enter: Details | q: Quit"
1275+ . to_string ( ) ,
1276+ SelectedView :: Producers => "1-6: Switch Views | Tab/←→: Navigate Views | f: Focus \
1277+ Mode | ↑↓: Select Producer | Enter: View Producer Details \
1278+ (Languages, Tools, SDKs) | q: Quit"
1279+ . to_string ( ) ,
1280+ SelectedView :: Details => {
1281+ "1-6: Switch Views | Tab/←→: Navigate Views | q: Quit" . to_string ( )
1282+ }
1283+ SelectedView :: Debug => {
1284+ "1-7: Switch Views | Tab/←→: Navigate Views | q: Quit" . to_string ( )
1285+ }
12741286 } ;
12751287
12761288 // Modify status bar text to include debug key when debug mode is enabled
@@ -1386,7 +1398,8 @@ fn main() -> io::Result<()> {
13861398 return Ok ( ( ) ) ;
13871399 }
13881400
1389- // Find the component path (first argument that's not a flag or the program name)
1401+ // Find the component path (first argument that's not a flag or the program
1402+ // name)
13901403 let component_path = match args
13911404 . iter ( )
13921405 . find ( |arg| !arg. starts_with ( '-' ) && !arg. ends_with ( "component_graph_view" ) )
@@ -1520,7 +1533,11 @@ fn main() -> io::Result<()> {
15201533 println ! ( " No producers section found in module #{}" , idx) ;
15211534 }
15221535 Err ( e) => {
1523- println ! ( " Error extracting producers section from module #{}: {}" , idx, e) ;
1536+ println ! (
1537+ " Error extracting producers section from module \
1538+ #{}: {}",
1539+ idx, e
1540+ ) ;
15241541 }
15251542 }
15261543 }
0 commit comments