Skip to content

A simple, lazy-friendly command-line tool to check the weather without ever leaving your terminal. Never get caught in the rain again, perfect for laundry days and outdoor plans. Built for fun. β˜”πŸŒ¦οΈ

Notifications You must be signed in to change notification settings

barbaracalderon/forecast-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Forecast CLI

A simple command-line tool to fetch and display weather forecasts using WeatherAPI and automatic location data from ipinfo.io.

Type forecast into your linux terminal and get a 6-day forecast to your current location.

Terminal Screenshot

Author

I'm Barbara Calderon, a software developer.

Features

Features

  • Current Weather: Displays real-time conditions including temperature, feels-like temperature, humidity, chance of rain, and weather description
  • 6-Day Forecast: Shows detailed daily forecasts with:
    • Average, minimum, and maximum temperatures
    • Precipitation chance
    • Weather conditions
    • Sunrise and sunset times
  • Automatic Location: Detects your location using your IP address (via ipinfo.io)
  • Custom Locations: Get weather for any city worldwide forecast --location "City Name"
  • Flexible API Keys: The default API key is read from the .env file but you can temporarily override it forecast --apiKey "your_api_key_here"
  • Easy Configuration: Stores API keys and settings in a .env file for secure and flexible usage, automatic config directory creation, clear error messages for missing configurations, launch.json file added for VSCode debugging tool.

About

What's the story behind this? Well, there actually is one.

One early Sunday morning, I woke up and jumped on the computer because I wanted to play around with some coding. I usually do this in the dark, with all the windows and doors closed shut and music pumping through my headphones. As you can see, I get very distracted.

About two hours in, I remembered I had to wash my laundry and hang the clothes out to dry in the sun in my backyard. Great! I got the laundry basket, detergent, fabric softener, and everything ready. Just as I was about to walk out the building door, I realized it had been raining hard.

How could I have missed this simple feature of nature?

Oh, right... I hadn’t opened the window to my room because I was too distracted coding away on the computer.

This is meant to change that. It comes in handy for me since maybe I’m too lazy to open a web browser, search for a weather site, type in my location, and scan for the useful data I want. Every. Single. Time.

So, considering that the first webcam ever invented was designed to monitor a coffee pot so developers would know when to grab coffee instead of checking it when it wasn’t ready, I thought to myself... hey, why not?

That’s how Forecast CLI was created.

I hope you find it as useful as I do.

Installation

Prerequisites

  • Go 1.21 or higher installed on your system
  • API keys for WeatherAPI

Steps

  1. Clone the Repository:
    git clone https://github.com/barbaracalderon/forecast-cli.git
    cd forecast-cli
  2. Set up the Configuration:
  • Create the config directory
mkdir -p ~/.config/forecast-cli
  • Move the .env file to the config directory
mv /path/to/forecast-cli/.env ~/.config/forecast-cli/
  1. Edit the .env File:
  • Open the .env file and add your API Keys from weatherapi.com, this way you have them stored and does not need to send it through the --apiKeys flag
WEATHERAPI_API_KEY=your_weatherapi_key_here
  1. Build:
go build -o forecast
  1. Install the Binary:
  • Move the binary to a directory in your PATH (e.g., /usr/local/bin):
sudo mv forecast /usr/local/bin/

Usage

Basic Usage:

forecast

Check weather in specific location:

forecast --location "Rio de Janeiro"

Use temporary API key:

forecast --apiKey "your_api_key_here"

Combine options:

forecast --location "FlorianΓ³polis" --apiKey "your_api_key_here"

Example output:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 🌍 Location: FlorianΓ³polis, Santa Catarina, BR             
β”‚ πŸ“… Date: 23/03 | Sunday                                    
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 🌑️ Current: partly cloudy, 24Β°C (Feels like 36Β°C)          
β”‚ πŸ”½ Min: 21Β°C | πŸ”Ό Max: 28Β°C                                
β”‚ πŸ’§ Humidity: 70%                                           
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“… 6-Day Forecast:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Date    β”‚ Temp (Β°C) β”‚ Rain Chance β”‚      Condition       β”‚ Sunrise  β”‚  Sunset  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 23/03 Sun β”‚ 24        β”‚ 1%          β”‚ patchy rain nearby   β”‚ 06:19 AM β”‚ 06:21 PM β”‚
β”‚ 24/03 Mon β”‚ 24        β”‚ 9%          β”‚ moderate rain        β”‚ 06:20 AM β”‚ 06:20 PM β”‚
β”‚ 25/03 Tue β”‚ 22        β”‚ 1%          β”‚ patchy rain nearby   β”‚ 06:20 AM β”‚ 06:19 PM β”‚
β”‚ 26/03 Wed β”‚ 22        β”‚ 5%          β”‚ moderate rain        β”‚ 06:21 AM β”‚ 06:18 PM β”‚
β”‚ 27/03 Thu β”‚ 22        β”‚ 5%          β”‚ patchy rain nearby   β”‚ 06:21 AM β”‚ 06:17 PM β”‚
β”‚ 28/03 Fri β”‚ 22        β”‚ 3%          β”‚ patchy rain nearby   β”‚ 06:22 AM β”‚ 06:16 PM β”‚
β”‚ 29/03 Sat β”‚ 24        β”‚ 0%          β”‚ partly cloudy        β”‚ 06:22 AM β”‚ 06:15 PM β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Dependencies

The project uses the following services and libraries:

  • WeatherAPI: For fetching weather data
  • IpInfo.io: For detecting the user's location based on their IP Address
  • Godotenv: For loading environment variables from the .env file

Contributing

Contributions are welcome. If you'd like to contribute, please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature or bugfix
  3. Submit a pull request with a detailed description of your changes

License

This project is under the GNU General Public Licence v3.0

Version History

Version Date Description
1.1.0 26th March 2025 Added --location and --apiKey flags.
1.0.0 23rd March 2025 Initial realease with basic forecast functionality.

About

A simple, lazy-friendly command-line tool to check the weather without ever leaving your terminal. Never get caught in the rain again, perfect for laundry days and outdoor plans. Built for fun. β˜”πŸŒ¦οΈ

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages