diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-24 18:39:12 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-24 18:39:12 +0200 |
| commit | a2041a3d337afdc236d3c323957c0d581d32234a (patch) | |
| tree | 0fdf8caa473da0a04154289a107d4e43fc8549ff /src/bin/client/repl.rs | |
| parent | v0.2.0: lock game mode (ESC/Q to exit), bump version (diff) | |
| download | zagan-bet-a2041a3d337afdc236d3c323957c0d581d32234a.tar.gz zagan-bet-a2041a3d337afdc236d3c323957c0d581d32234a.zip | |
Add hosts command, info shows current host+fingerprint, disconnect-before-connect, default port 11525
Diffstat (limited to '')
| -rw-r--r-- | src/bin/client/repl.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/bin/client/repl.rs b/src/bin/client/repl.rs index 40b267e..dd55acc 100644 --- a/src/bin/client/repl.rs +++ b/src/bin/client/repl.rs | |||
| @@ -273,11 +273,15 @@ impl ClientState { | |||
| 273 | } | 273 | } |
| 274 | } | 274 | } |
| 275 | "connect" => { | 275 | "connect" => { |
| 276 | if self.stream.is_some() { | ||
| 277 | println!("\nAlready connected. Disconnect first."); | ||
| 278 | continue 'outer; | ||
| 279 | } | ||
| 276 | let addr_str = if parts.len() < 2 { | 280 | let addr_str = if parts.len() < 2 { |
| 277 | if let Some(h) = &self.addr { | 281 | if let Some(h) = &self.addr { |
| 278 | h.clone() | 282 | h.clone() |
| 279 | } else { | 283 | } else { |
| 280 | println!("\nNo host specified and no previous connection. Usage: connect <ip>:<port>"); | 284 | println!("\nNo host specified. Usage: connect <ip>:<port>"); |
| 281 | continue 'outer; | 285 | continue 'outer; |
| 282 | } | 286 | } |
| 283 | } else { | 287 | } else { |
| @@ -591,6 +595,20 @@ impl ClientState { | |||
| 591 | Err(e) => println!("\nFailed to forget host: {}", e), | 595 | Err(e) => println!("\nFailed to forget host: {}", e), |
| 592 | } | 596 | } |
| 593 | } | 597 | } |
| 598 | "hosts" => { | ||
| 599 | let hosts = database::get_all_hosts(&self.conn); | ||
| 600 | if hosts.is_empty() { | ||
| 601 | println!("\nNo remembered hosts."); | ||
| 602 | } else { | ||
| 603 | println!("\nRemembered hosts:"); | ||
| 604 | for (host, fp) in &hosts { | ||
| 605 | match fp { | ||
| 606 | Some(fp) => println!(" {} - {}", host, fp), | ||
| 607 | None => println!(" {} - (no fingerprint)", host), | ||
| 608 | } | ||
| 609 | } | ||
| 610 | } | ||
| 611 | } | ||
| 594 | _ => help(), | 612 | _ => help(), |
| 595 | } | 613 | } |
| 596 | break; | 614 | break; |
| @@ -752,6 +770,7 @@ fn get_commands() -> Vec<String> { | |||
| 752 | "help".to_string(), | 770 | "help".to_string(), |
| 753 | "quit".to_string(), | 771 | "quit".to_string(), |
| 754 | "forget-host".to_string(), | 772 | "forget-host".to_string(), |
| 773 | "hosts".to_string(), | ||
| 755 | ] | 774 | ] |
| 756 | } | 775 | } |
| 757 | 776 | ||
