MCPcopy Index your code
hub / github.com/algoscienceacademy/RustUI / main

Function main

src/main.rs:10–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8use std::io::{stdout, Write};
9
10fn main() -> Result<(), Box<dyn std::error::Error>> {
11 let mut dev_server = DevServer::new();
12 dev_server.watch(".")?;
13
14 enable_raw_mode()?;
15 loop {
16 // Clear screen and draw UI
17 execute!(
18 stdout(),
19 Clear(ClearType::All),
20 cursor::MoveTo(0, 0),
21 SetForegroundColor(Color::Green),
22 Print("RustUI Development Server\n"),
23 SetForegroundColor(Color::White),
24 )?;
25
26 // Display status
27 let status = dev_server.get_status();
28 print_status(&status)?;
29
30 // Display controls
31 println!("\nControls:");
32 println!("r - Reload | s - Reopen | q - Quit");
33 println!("1-4 - Switch Platform");
34
35 // Handle events with proper error checking
36 match event::read() {
37 Ok(Event::Key(key_event)) => {
38 match key_event.code {
39 KeyCode::Char('r') => dev_server.rebuild(),
40 KeyCode::Char('s') => {
41 dev_server = DevServer::new();
42 dev_server.watch(".")?;
43 }
44 KeyCode::Char('1') => dev_server.set_platform(Platform::Desktop),
45 KeyCode::Char('2') => dev_server.set_platform(Platform::IOS),
46 KeyCode::Char('3') => dev_server.set_platform(Platform::Android),
47 KeyCode::Char('4') => dev_server.set_platform(Platform::Web),
48 KeyCode::Char('q') => break,
49 _ => {}
50 }
51 }
52 Err(e) => {
53 return Err(Box::new(e));
54 }
55 _ => {}
56 }
57 }
58
59 disable_raw_mode()?;
60 Ok(())
61}
62
63fn print_status(status: &BuildStatus) -> Result<(), Box<dyn std::error::Error>> {
64 let status_color = if status.in_progress {

Callers

nothing calls this directly

Calls 5

print_statusFunction · 0.85
watchMethod · 0.80
get_statusMethod · 0.80
rebuildMethod · 0.80
set_platformMethod · 0.80

Tested by

no test coverage detected