📡 Project: Weather CLI Tool

📚 Lesson 11: Fetch Live Data ⏱ 35-40 min 📊 Advanced
🎯 Objective

Build a complete weather CLI tool that fetches and displays weather data. Practice API integration, caching, command-line argument parsing, and formatted output display.

Requirements

  1. Create a WeatherService class that simulates API calls
  2. Support commands: current, forecast, compare
  3. Implement a simple cache to avoid repeated API calls
  4. Display formatted weather with emoji indicators
  5. Support multiple cities comparison
  6. Handle API errors and timeouts gracefully

Expected Output

Terminal
$ dart run weather.dart current London
🌤️  Weather for London, GB
─────────────────────────────────────
🌡️  Temperature: 15°C (Feels like: 13°C)
💧 Humidity: 78%
🌬️  Wind: 12 km/h SW
📋 Conditions: Rainy
─────────────────────────────────────
💡 Tip: Bring an umbrella!

$ dart run weather.dart forecast Tokyo
📅 5-Day Forecast for Tokyo, JP
─────────────────────────────────────
Mon: ☀️ 28°C | Sunny
Tue: ⛅ 26°C | Partly Cloudy
Wed: 🌧️ 22°C | Rainy
Thu: ☀️ 29°C | Clear Sky
Fri: ⛅ 27°C | Partly Cloudy

$ dart run weather.dart compare London Tokyo Dubai
📊 Weather Comparison
─────────────────────────────────────
🌤️  London     | 15°C | Rainy
☀️  Tokyo      | 28°C | Sunny
🔥 Dubai      | 38°C | Hot
─────────────────────────────────────
🔥 Hottest: Dubai (38°C)
❄️  Coldest: London (15°C)