diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-29 22:16:15 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-29 22:16:15 +0100 |
| commit | bc0de9955c375cf27d52c9934403964205afc182 (patch) | |
| tree | 42799fb426fb0ec164f44c92a63525003c582f35 /src/bin/client/repl.rs | |
| parent | initial connection timeout set to 10s (diff) | |
| download | zagan-bet-bc0de9955c375cf27d52c9934403964205afc182.tar.gz zagan-bet-bc0de9955c375cf27d52c9934403964205afc182.zip | |
formatting
Diffstat (limited to '')
| -rw-r--r-- | src/bin/client/repl.rs | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/bin/client/repl.rs b/src/bin/client/repl.rs index 7fa462a..9af4ea9 100644 --- a/src/bin/client/repl.rs +++ b/src/bin/client/repl.rs | |||
| @@ -1,14 +1,14 @@ | |||
| 1 | use rusqlite::Connection; | 1 | use rusqlite::Connection; |
| 2 | use std::io::{stdout, Write}; | 2 | use std::io::{Write, stdout}; |
| 3 | use std::sync::{Arc, Mutex}; | 3 | use std::sync::{Arc, Mutex}; |
| 4 | use std::time::Instant; | 4 | use std::time::Instant; |
| 5 | 5 | ||
| 6 | use crossterm::{ | 6 | use crossterm::{ |
| 7 | cursor::{MoveToColumn, MoveUp, Show}, | 7 | cursor::{MoveToColumn, MoveUp, Show}, |
| 8 | event::{read, Event, KeyCode, KeyEventKind, KeyModifiers}, | 8 | event::{Event, KeyCode, KeyEventKind, KeyModifiers, read}, |
| 9 | execute, | 9 | execute, |
| 10 | style::Stylize, | 10 | style::Stylize, |
| 11 | terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType}, | 11 | terminal::{Clear, ClearType, disable_raw_mode, enable_raw_mode}, |
| 12 | }; | 12 | }; |
| 13 | 13 | ||
| 14 | use sha2::{Digest, Sha256}; | 14 | use sha2::{Digest, Sha256}; |
| @@ -20,7 +20,7 @@ use zagan_bet::client::ui::{ | |||
| 20 | visual_line_count, | 20 | visual_line_count, |
| 21 | }; | 21 | }; |
| 22 | use zagan_bet::protocol::io_failure_message; | 22 | use zagan_bet::protocol::io_failure_message; |
| 23 | use zagan_bet::roulette::{color as roulette_color, WHEEL}; | 23 | use zagan_bet::roulette::{WHEEL, color as roulette_color}; |
| 24 | 24 | ||
| 25 | use crate::connection::TlsStream; | 25 | use crate::connection::TlsStream; |
| 26 | 26 | ||
| @@ -71,8 +71,7 @@ impl ClientState { | |||
| 71 | self.core.set_connected(true); | 71 | self.core.set_connected(true); |
| 72 | self.core.set_logged_in(authed_user); | 72 | self.core.set_logged_in(authed_user); |
| 73 | let fingerprint = database::get_fingerprint(&self.conn, addr); | 73 | let fingerprint = database::get_fingerprint(&self.conn, addr); |
| 74 | self.core | 74 | self.core.set_host_info(Some(addr.to_string()), fingerprint); |
| 75 | .set_host_info(Some(addr.to_string()), fingerprint); | ||
| 76 | database::save_host(&self.conn, addr); | 75 | database::save_host(&self.conn, addr); |
| 77 | } | 76 | } |
| 78 | Err(e) => { | 77 | Err(e) => { |
| @@ -178,12 +177,9 @@ impl ClientState { | |||
| 178 | Effect::Print(lines) => { | 177 | Effect::Print(lines) => { |
| 179 | self.commit_prompt_line(); | 178 | self.commit_prompt_line(); |
| 180 | for line in lines { | 179 | for line in lines { |
| 181 | let rendered = if line.starts_with("ERROR") | 180 | let rendered = if line.starts_with("ERROR") || line.contains("failed") { |
| 182 | || line.contains("failed") | ||
| 183 | { | ||
| 184 | line.as_str().red().to_string() | 181 | line.as_str().red().to_string() |
| 185 | } else if line.starts_with("Logged in") | 182 | } else if line.starts_with("Logged in") || line.starts_with("Successfully") |
| 186 | || line.starts_with("Successfully") | ||
| 187 | { | 183 | { |
| 188 | line.as_str().green().to_string() | 184 | line.as_str().green().to_string() |
| 189 | } else if line.starts_with("Available commands:") | 185 | } else if line.starts_with("Available commands:") |
| @@ -249,10 +245,7 @@ impl ClientState { | |||
| 249 | Effect::ForgetHost(target) => { | 245 | Effect::ForgetHost(target) => { |
| 250 | self.commit_prompt_line(); | 246 | self.commit_prompt_line(); |
| 251 | match database::forget_host(&self.conn, &target) { | 247 | match database::forget_host(&self.conn, &target) { |
| 252 | Ok(_) => println!( | 248 | Ok(_) => println!("Cleared trust and stored credentials for {}.", target), |
| 253 | "Cleared trust and stored credentials for {}.", | ||
| 254 | target | ||
| 255 | ), | ||
| 256 | Err(error) => println!("Failed to forget host: {}", error), | 249 | Err(error) => println!("Failed to forget host: {}", error), |
| 257 | } | 250 | } |
| 258 | } | 251 | } |
| @@ -297,9 +290,7 @@ impl ClientState { | |||
| 297 | let roulette = lines | 290 | let roulette = lines |
| 298 | .first() | 291 | .first() |
| 299 | .is_some_and(|first| first.contains("ROULETTE")); | 292 | .is_some_and(|first| first.contains("ROULETTE")); |
| 300 | let crash = lines | 293 | let crash = lines.first().is_some_and(|first| first.contains("CRASH")); |
| 301 | .first() | ||
| 302 | .is_some_and(|first| first.contains("CRASH")); | ||
| 303 | let rendered: Vec<String> = lines | 294 | let rendered: Vec<String> = lines |
| 304 | .iter() | 295 | .iter() |
| 305 | .map(|line| { | 296 | .map(|line| { |
