A command-line application written in Rust that fetches and displays the current Premier League standings with fancy colored output and filtering options.
- football-data.org - Free tier (10 requests/minute)
- Endpoint:
https://api.football-data.org/v4/competitions/PL/standings - Requires free API key (no credit card needed)
clap = { version = "4.5", features = ["derive"] } # CLI argument parsing
reqwest = { version = "0.11", features = ["json", "blocking"] } # HTTP requests
serde = { version = "1.0", features = ["derive"] } # JSON serialization
serde_json = "1.0" # JSON parsing
comfy-table = "7.1" # Fancy table output
anyhow = "1.0" # Error handling
dotenvy = "0.15" # Environment variablespl-table-cli/
├── Cargo.toml # Project configuration and dependencies
├── .env # API key (gitignored)
├── .env.example # Template for API key
├── .gitignore # Git ignore rules
├── plan.md # This file
├── getting-started.md # Learning guide
├── src/
│ ├── main.rs # Entry point
│ ├── cli.rs # CLI argument definitions
│ ├── api/
│ │ ├── mod.rs # Module declaration
│ │ ├── client.rs # HTTP client wrapper
│ │ └── models.rs # Data structures for API responses
│ └── display/
│ ├── mod.rs # Module declaration
│ └── table.rs # Table formatting logic
- Fetch Premier League standings from API
- Parse JSON response
- Display basic table with: Position, Team, Played, Won, Drawn, Lost, GF, GA, GD, Points
- Proper error handling
- Color coding:
- Positions 1-4: Green (Champions League)
- Position 5: Yellow (Europa League)
- Position 6: Cyan (Europa Conference League)
- Positions 18-20: Red (Relegation)
- Pretty table formatting with borders
pl-table- Show full tablepl-table --team Arsenal- Filter/highlight specific teampl-table --form- Show last 5 games (W/D/L)pl-table --top 6- Show only top N teams
- Loading indicator while fetching data
- User-friendly error messages
- Caching to respect API rate limits
- Help documentation
{
"standings": [
{
"table": [
{
"position": 1,
"team": {
"name": "Arsenal FC",
"crest": "url"
},
"playedGames": 22,
"won": 16,
"draw": 4,
"lost": 2,
"goalsFor": 50,
"goalsAgainst": 20,
"goalDifference": 30,
"points": 52,
"form": "W,W,D,W,W"
}
]
}
]
}- Cargo - Rust's package manager and build tool
- Ownership & Borrowing - Rust's memory safety features
- Structs & Enums - Data structures
- Traits - Similar to interfaces
- Result & Option - Error handling
- Modules - Code organization
- Derive Macros - Automatic code generation
- Pattern Matching - Powerful control flow
- Write code
cargo check- Quick compile checkcargo build- Compile the projectcargo run- Build and runcargo run -- --help- Run with arguments