From 145a61e1aaced816cfc74b19d0713c265787018e Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 13:23:10 +0100 Subject: [PATCH] :art: Add CLI Parameter --- tools/generate_freieshacken_events.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/generate_freieshacken_events.py b/tools/generate_freieshacken_events.py index 3bae5ac..668f0de 100644 --- a/tools/generate_freieshacken_events.py +++ b/tools/generate_freieshacken_events.py @@ -1,5 +1,6 @@ import os import datetime +import sys layout = "event" title = "Freies Hacken" @@ -37,19 +38,23 @@ event_date: {year}-{month:02d}-{day:02d} print(f"Markdown file '{filename}' generated successfully in the '{folder_path}' folder!") +if len(sys.argv) < 2: + print(f"Usage: python3 {sys.argv[0]} ") + sys.exit() + # Input year -input_year = int(input("Enter the year: ")) +year = int(sys.argv[1]) # Calculate Wednesdays for month in range(1, 13): for day in range(1, 32): try: # Generate a date object - current_date = datetime.date(input_year, month, day) + current_date = datetime.date(year, month, day) # Check if the date is a Wednesday if current_date.weekday() == 2: - generate_markdown_file(input_year, month, day) + generate_markdown_file(year, month, day) except ValueError: # If the day is out of range for the month, skip to the next month