Skip to content

Latest commit

 

History

History
116 lines (103 loc) · 3.71 KB

File metadata and controls

116 lines (103 loc) · 3.71 KB

Premier League Table CLI - Technical Plan

Project Overview

A command-line application written in Rust that fetches and displays the current Premier League standings with fancy colored output and filtering options.

Technology Stack

API

  • 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)

Rust Dependencies

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 variables

Project Structure

pl-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

Features

Phase 1: Basic Functionality

  • 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

Phase 2: Enhanced Display

  • 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

Phase 3: CLI Features

  • pl-table - Show full table
  • pl-table --team Arsenal - Filter/highlight specific team
  • pl-table --form - Show last 5 games (W/D/L)
  • pl-table --top 6 - Show only top N teams

Phase 4: Polish

  • Loading indicator while fetching data
  • User-friendly error messages
  • Caching to respect API rate limits
  • Help documentation

API Response Structure (Simplified)

{
  "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"
        }
      ]
    }
  ]
}

Key Rust Concepts You'll Learn

  1. Cargo - Rust's package manager and build tool
  2. Ownership & Borrowing - Rust's memory safety features
  3. Structs & Enums - Data structures
  4. Traits - Similar to interfaces
  5. Result & Option - Error handling
  6. Modules - Code organization
  7. Derive Macros - Automatic code generation
  8. Pattern Matching - Powerful control flow

Development Workflow

  1. Write code
  2. cargo check - Quick compile check
  3. cargo build - Compile the project
  4. cargo run - Build and run
  5. cargo run -- --help - Run with arguments