import click
import requests
from datetime import datetime, timedelta
# Placeholder for real GCal and weather integration
EVENTS = [
{"title": "Standup Meeting", "time": "10:00", "date": "2025-04-16", "location": "Remote"},
{"title": "Doctor Appointment", "time": "15:00", "date": "2025-04-16", "location": "City Clinic"},
]
@click.group()
def cli():
pass
@cli.command()
def today():
click.echo("📅 Today's Events:")
today = datetime.today().strftime('%Y-%m-%d')
for e in EVENTS:
if e["date"] == today:
click.echo(f"- {e['time']}: {e['title']} 📍 {e['location']}")
@cli.command()
@click.option('--title', prompt='Event title')
@click.option('--date', prompt='Event date (YYYY-MM-DD)')
@click.option('--time', prompt='Event time (HH:MM)')
@click.option('--location', prompt='Event location')
def add(title, date, time, location):
EVENTS.append({"title": title, "date": date, "time": time, "location": location})
click.echo("✅ Event created successfully!")
@cli.command()
def forecast():
if not EVENTS:
click.echo("No events to check weather for.")
return
event = EVENTS[-1]
click.echo(f"🌦 Forecast for: {event['title']}")
weather = get_weather(event['location'])
click.echo(f"📍 Location: {event['location']} | Date: {event['date']}")
click.echo(f"☁️ Weather Forecast: {weather}")
def get_weather(city):
API_KEY = "your_openweathermap_api_key"
url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&units=metric"
r = requests.get(url)
if r.status_code == 200:
data = r.json()
return f"{data['weather'][0]['main']}, {data['main']['temp']}°C"
return "Weather data unavailable"
if __name__ == '__main__':
cli()
No comments:
Post a Comment