(&mut self)
| 124 | } |
| 125 | |
| 126 | pub fn run(&mut self) -> Result<(), Box<dyn std::error::Error>> { |
| 127 | use crossterm::{ |
| 128 | event::{self, Event, KeyCode}, |
| 129 | terminal::{disable_raw_mode, enable_raw_mode}, |
| 130 | }; |
| 131 | |
| 132 | enable_raw_mode()?; |
| 133 | |
| 134 | // Show welcome screen first |
| 135 | self.render_welcome_screen()?; |
| 136 | |
| 137 | loop { |
| 138 | self.render_ui()?; |
| 139 | |
| 140 | if let Ok(Event::Key(key_event)) = event::read() { |
| 141 | match key_event.code { |
| 142 | KeyCode::Char('q') => break, |
| 143 | KeyCode::Char('1') => { |
| 144 | self.set_platform(Platform::Desktop); |
| 145 | self.show_platform_setup("Desktop")?; |
| 146 | }, |
| 147 | KeyCode::Char('2') => { |
| 148 | self.set_platform(Platform::IOS); |
| 149 | self.show_platform_setup("iOS")?; |
| 150 | }, |
| 151 | KeyCode::Char('3') => { |
| 152 | self.set_platform(Platform::Android); |
| 153 | self.show_platform_setup("Android")?; |
| 154 | }, |
| 155 | KeyCode::Char('4') => { |
| 156 | self.set_platform(Platform::Web); |
| 157 | self.show_platform_setup("Web")?; |
| 158 | }, |
| 159 | KeyCode::Char('r') => { |
| 160 | if self.is_platform_selected() { |
| 161 | self.rebuild(); |
| 162 | } |
| 163 | }, |
| 164 | KeyCode::Char('s') => { |
| 165 | if self.is_platform_selected() { |
| 166 | self.restart()?; |
| 167 | } |
| 168 | }, |
| 169 | _ => {} |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | disable_raw_mode()?; |
| 175 | Ok(()) |
| 176 | } |
| 177 | |
| 178 | fn is_platform_selected(&self) -> bool { |
| 179 | !matches!(self.get_status().message, None) |
nothing calls this directly
no test coverage detected