A command-line weather application built with Rust that fetches and displays current weather conditions and forecasts for any location using the Visual Crossing Weather API.
- Fetch current weather conditions with real-time data
- Display detailed forecast for today and tomorrow
- Clean, formatted output with temperature (Fahrenheit), humidity, conditions, and descriptions
- Support for any location worldwide
- Environment variable configuration for API key
- Automatic timezone handling for accurate local dates and times
- Rust 1.70 or higher
- Visual Crossing Weather API key (get one free at visualcrossing.com)
- Clone the repository:
git clone git@github.com:ishworii/weather_cli.git
cd weather_cli- Create a
.envfile in the project root:
echo "API_KEY=your_api_key_here" > .env- Build the project:
cargo build --releaseRun the application with a location as an argument:
cargo run -- <location># Get weather for Kathmandu
cargo run -- Kathmandu
# Get weather for New York
cargo run -- "New York"
# Get weather for London
cargo run -- London╔══════════════════════════════════════════════════════════╗
║ CURRENT WEATHER CONDITIONS ║
╚══════════════════════════════════════════════════════════╝
Date: 2025-10-10 (Time: 18:30:00)
Temperature: 75.8°F
Humidity: 88.6%
Conditions: Partially cloudy
╔══════════════════════════════════════════════════════════╗
║ FORECAST FOR TODAY ║
╚══════════════════════════════════════════════════════════╝
Date: 2025-10-10
Temperature: 78.0°F
High/Low: 80.1°F / 75.3°F
Humidity: 90.9%
Conditions: Rain, Partially cloudy
Description: Partly cloudy throughout the day with storms possible.
╔══════════════════════════════════════════════════════════╗
║ FORECAST FOR TOMORROW ║
╚══════════════════════════════════════════════════════════╝
Date: 2025-10-11
Temperature: 79.8°F
High/Low: 83.0°F / 76.9°F
Humidity: 86.2%
Conditions: Rain, Partially cloudy
Description: Partly cloudy throughout the day with storms possible.
weather_cli/
├── src/
│ ├── main.rs # Entry point and CLI parsing
│ ├── lib.rs # Main application logic
│ ├── api.rs # API client implementation
│ ├── config.rs # Configuration management
│ └── weather.rs # Weather data structures and Display trait
├── Cargo.toml
├── .env # API key (not committed)
└── README.md
reqwest- HTTP client for API requeststokio- Async runtimeserde/serde_json- JSON serialization/deserializationclap- Command-line argument parsingdotenvy- Environment variable managementchrono- Date and time handling
The application requires an API key from Visual Crossing Weather API. Set it in a .env file:
API_KEY=your_api_key_here
The application handles common errors such as:
- Invalid API key
- Network connectivity issues
- Invalid location names
- JSON parsing errors
This project is available under the MIT License.