soccercloud-rust/README.md

187 lines
3.6 KiB
Markdown
Raw Normal View History

2026-02-10 20:40:10 -05:00
# SoccerCloud CLI (Rust)
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
Terminal-native rebuild of MentalNet SoccerCloud with a cloud-dashboard feel.
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
## Overview
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
This project is a Rust TUI/CLI soccer simulator with:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
- Single Match, 4-Team League, and 4-Team Knockout modes
- Live match logs, scoreboard, and instance lifecycle controls
- Seeded deterministic runs (`--seed`) for reproducible results
- CSV export for single, league, and knockout outputs
- Expanded team pool (clubs + 50+ national teams, including `PRC China`)
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
## Requirements
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
- Rust toolchain (stable)
- Cargo
- A terminal that supports UTF-8 and colors
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
Install Rust (if needed):
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
## Setup
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
Clone and build:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
git clone <your-repo-url>
cd soccercloud-cli
cargo check
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
Run in debug mode:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run
2025-10-20 21:32:45 -04:00
```
2026-02-10 20:40:10 -05:00
Build optimized binary:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo build --release
./target/release/soccercloud
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
## CLI Usage
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
Default (interactive TUI):
2025-10-20 21:32:45 -04:00
```bash
2026-02-10 20:40:10 -05:00
soccercloud
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
or with Cargo:
2025-10-20 21:32:45 -04:00
```bash
2026-02-10 20:40:10 -05:00
cargo run --
2025-10-20 21:32:45 -04:00
```
2026-02-10 20:40:10 -05:00
Use a global seed for reproducibility:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run -- --seed 42
```
2025-10-20 21:32:45 -04:00
2026-02-11 11:57:27 -05:00
### Web mode (Actix)
Launch the web UI on port `9009`:
```bash
cargo run -- --web
```
Then open:
```text
http://127.0.0.1:9009
```
Notes:
- The web frontend (`index.html` + `data.js`) now uses Rust backend APIs.
- Simulation logic runs server-side in Rust (shared with CLI/TUI engine).
2026-02-10 20:40:10 -05:00
### Quick match (headless)
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run -- quick --home "Arsenal" --away "Real Madrid" --seed 42
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
CPU auto-fill for missing team(s):
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run -- quick --home "England" --seed 42
cargo run -- quick --seed 42
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
### List teams
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run -- list
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
### Export CSV
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
Single:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run -- export --mode single --team "Arsenal" --team "PRC China" --out match.csv --seed 42
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
League:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run -- export --mode league4 --team "England" --team "Brazil" --team "Japan" --team "Germany" --out league.csv --seed 42
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
Knockout:
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
```bash
cargo run -- export --mode knockout4 --team "France" --team "Argentina" --team "Morocco" --team "PRC China" --out knockout.csv --seed 42
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
## TUI Controls
Global:
- `n` create Single instance
- `l` create League4 instance
- `o` create Knockout4 instance
- `s` start selected instance
- `c` clone selected instance
- `d` delete selected instance
- `e` export selected instance CSV
- `v` or `Enter` toggle dashboard/detail
- `j/k` or `Up/Down` navigate instances
- `1/2/4/0` speed control (1x/2x/4x/instant)
- `q` quit
Create modal:
- `m` set selected slot to manual team
- `p` set selected slot to CPU auto-fill
- `[` / `]` or `Left/Right` cycle manual team
- `Enter` create
- `Esc` cancel
Readable fullscreen data panels:
- `t` stats modal
- `g` standings/bracket modal
- `h` history modal
- `j/k` or `Up/Down` scroll inside modal
- `Esc` or `q` close modal
## Project Structure
```text
src/
├── main.rs # CLI entrypoint and commands
2026-02-11 11:57:27 -05:00
├── web.rs # Actix web server + JSON APIs
2026-02-10 20:40:10 -05:00
├── app.rs # App state and event loop
├── data.rs # Teams, flags, tactics, profiles
├── sim.rs # Match/league/knockout simulation engine
├── instance.rs # Simulation instance lifecycle and state
├── export.rs # CSV export
├── utils.rs # RNG + helper utilities
└── ui/
├── mod.rs
├── dashboard.rs
├── detail.rs
├── modal.rs
└── widgets.rs
```
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
## Notes
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
- Dependency policy is intentionally strict (minimal crates).
- Team data is embedded in the binary (no external runtime data files).
- Use `--seed` for deterministic comparisons and debugging.
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
## License
2025-10-20 21:32:45 -04:00
2026-02-10 20:40:10 -05:00
MIT