2 unstable releases
0.3.0 | Jan 28, 2024 |
---|---|
0.2.0 |
|
0.1.0 | Jan 28, 2024 |
#1858 in Command line utilities
40 downloads per month
13KB
91 lines
Weather Forecast CLI
This is a simple command-line interface (CLI) application that fetches weather forecast data from the OpenWeatherMap API based on the provided city and country code.
Prerequisites
- Rust: Make sure you have Rust installed on your system.
Installation
Clone the repository:
git clone https://github.com/tusharpamnani/Weather-Forecast.git
cd Weather-Forecast
Build the project:
cargo build --release
Usage
-
Add your API key: Open the
src/main.rs
file and add your OpenWeatherMap API key to the following line (line 89):"https://api.openweathermap.org/data/2.5/weather?q={},{}&appid={YOUR_API_KEY}&units=metric",
-
Run the CLI:
cargo run <CITY> <COUNTRY_CODE>
Replace
<CITY>
with the name of the city and<COUNTRY_CODE>
with the country code (e.g., "ind" for India).Example:
cargo run nagpur ind
Output
The CLI will display information about the provided city's weather forecast, including temperature, description, humidity, wind speed and direction, and sunrise/sunset times.
Example output:
Weather forecast for Nagpur (IND):
- Temperature: 19.01 °C
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- OpenWeatherMap for providing the weather forecast data through their API.
- reqwest for HTTP client functionality.
- serde for serialization and deserialization of JSON data.
- structopt for easy command-line argument parsing.
Dependencies
~9–20MB
~307K SLoC