39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import sys
|
|
from services.gsheet_client import GSheetClient
|
|
from mappers.sheet_mapper import SheetMapper
|
|
from mappers.markdown_builder import MarkdownBuilder
|
|
from services.readme_editor import ReadmeEditor
|
|
|
|
def main():
|
|
try:
|
|
print("🚀 Starting README update from Google Sheets...")
|
|
|
|
# 1. Fetch data from Google Sheets
|
|
client = GSheetClient()
|
|
raw_rows = client.fetch_data()
|
|
|
|
if not raw_rows:
|
|
print("⚠️ No data found in the spreadsheet or error occurred.")
|
|
return
|
|
|
|
# 2. Map raw rows to Core Models
|
|
report = SheetMapper.map_rows_to_report(raw_rows)
|
|
print(f"✅ Parsed {len(report.tasks)} tasks.")
|
|
|
|
# 3. Build Markdown content
|
|
markdown_content = MarkdownBuilder.build_table(report)
|
|
|
|
# 4. Update README.md
|
|
editor = ReadmeEditor()
|
|
if editor.update_section(markdown_content):
|
|
print("🎉 README.md successfully updated!")
|
|
else:
|
|
print("❌ Failed to update README.md.")
|
|
|
|
except Exception as e:
|
|
print(f"💥 An unexpected error occurred: {e}")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|