Skip to content

codeforgood-org/weather-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Weather CLI 🌀️

A simple, elegant command-line interface for fetching real-time weather information from OpenWeatherMap API.

Features

  • 🌍 Get weather for any city worldwide
  • 🌑️ Detailed weather information including temperature, humidity, wind speed, and more
  • πŸ”§ Configurable temperature units (Celsius, Fahrenheit, Kelvin)
  • πŸ” Secure API key management via environment variables
  • ✨ Clean, modular Python code with type hints
  • πŸ§ͺ Comprehensive error handling
  • πŸ“¦ Easy installation and setup

Installation

Prerequisites

  • Python 3.7 or higher
  • pip (Python package manager)
  • An OpenWeatherMap API key (get one free here)

Quick Install

  1. Clone this repository:
git clone https://github.com/codeforgood-org/weather-cli.git
cd weather-cli
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up your API key:
export OPENWEATHER_API_KEY='your_api_key_here'

Or create a .env file:

echo "OPENWEATHER_API_KEY=your_api_key_here" > .env

Package Installation (Optional)

Install as a package for system-wide access:

pip install -e .

Usage

Basic Usage

Get weather for a city:

python -m weather_cli.cli London

Or if installed as a package:

weather-cli London

Multi-word City Names

For cities with spaces in their names:

python -m weather_cli.cli New York
python -m weather_cli.cli San Francisco

Temperature Units

Choose your preferred temperature unit:

# Celsius (default)
python -m weather_cli.cli Tokyo

# Fahrenheit
python -m weather_cli.cli Tokyo --units imperial

# Kelvin
python -m weather_cli.cli Tokyo --units standard

Examples

# Get weather for Paris
$ python -m weather_cli.cli Paris

Weather in Paris, FR:
  Description: Clear sky
  Temperature: 18.5Β°C (feels like 17.8Β°C)
  Humidity: 65%
  Pressure: 1015 hPa
  Wind Speed: 3.5 m/s
  Cloudiness: 10%

Development

Project Structure

weather-cli/
β”œβ”€β”€ weather_cli/           # Main package directory
β”‚   β”œβ”€β”€ __init__.py       # Package initialization
β”‚   β”œβ”€β”€ cli.py            # Command-line interface
β”‚   β”œβ”€β”€ config.py         # Configuration management
β”‚   └── weather.py        # Weather data fetching and processing
β”œβ”€β”€ tests/                # Test directory
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_config.py
β”‚   β”œβ”€β”€ test_weather.py
β”‚   └── test_cli.py
β”œβ”€β”€ .env.example          # Example environment variables
β”œβ”€β”€ .gitignore            # Git ignore rules
β”œβ”€β”€ LICENSE               # MIT License
β”œβ”€β”€ README.md             # This file
β”œβ”€β”€ requirements.txt      # Production dependencies
β”œβ”€β”€ requirements-dev.txt  # Development dependencies
└── pyproject.toml        # Project configuration

Running Tests

Install development dependencies:

pip install -r requirements-dev.txt

Run tests:

pytest

Run tests with coverage:

pytest --cov=weather_cli --cov-report=html

Code Quality

This project uses various tools to maintain code quality:

# Format code with black
black weather_cli tests

# Sort imports
isort weather_cli tests

# Lint with flake8
flake8 weather_cli tests

# Type checking with mypy
mypy weather_cli

Configuration

Environment Variables

  • OPENWEATHER_API_KEY (required): Your OpenWeatherMap API key
  • WEATHER_UNITS (optional): Default temperature units (metric, imperial, or standard)

Getting an API Key

  1. Visit OpenWeatherMap
  2. Sign up for a free account
  3. Navigate to API Keys section
  4. Generate a new API key
  5. Add it to your environment variables

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and follow the code style guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue if your problem isn't already listed
  3. Provide as much detail as possible including error messages and your environment

Roadmap

Future enhancements planned:

  • 5-day weather forecast
  • Multiple city comparison
  • Weather alerts and notifications
  • Historical weather data
  • Colorized terminal output
  • JSON output format option
  • Configuration file support

Made with Python 🐍

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •