src/dlw/commands.py aktualisiert

This commit is contained in:
Kim Diallo 2026-01-03 02:31:51 +01:00
parent fef09ead53
commit 83feeb6a64
1 changed files with 23 additions and 47 deletions

View File

@ -1,47 +1,23 @@
import os
import os import argparse
import sys from . import admin
import argparse
from . import admin def setup_environment():
print("Initialisiere Blog-Struktur...")
# Annahme: Das Repo-Root-Verzeichnis ist das aktuelle Arbeitsverzeichnis for folder in ['content', 'downloads']:
REPO_ROOT = os.getcwd() os.makedirs(folder, exist_ok=True)
print(f" -> {folder}/ erstellt.")
def setup_environment(): print("Setup abgeschlossen.")
"""Erstellt notwendige Verzeichnisse und initialisiert Pelican/Git-Struktur."""
print("Starte Setup...") def main():
parser = argparse.ArgumentParser(description="Forgejo Blog Manager CLI")
# 1. Sicherstellen, dass die Content-Verzeichnisse existieren parser.add_argument('action', choices=['setup', 'start'])
if not os.path.exists(os.path.join(REPO_ROOT, 'content')): args = parser.parse_args()
os.makedirs(os.path.join(REPO_ROOT, 'content'))
print(" -> 'content/' Verzeichnis erstellt.") if args.action == 'setup':
setup_environment()
if not os.path.exists(os.path.join(REPO_ROOT, 'downloads')): elif args.action == 'start':
os.makedirs(os.path.join(REPO_ROOT, 'downloads')) admin.app.run(host='127.0.0.1', port=5000)
print(" -> 'downloads/' Verzeichnis erstellt.")
if __name__ == '__main__':
# 2. To-Do: Hier müsste die initiale Pelican Konfiguration main()
# und Templates in das 'content'-Verzeichnis kopiert werden.
print("Setup abgeschlossen. Bereit für 'blog-cli start'")
def start_server(host='127.0.0.1', port=5000):
"""Startet den Flask Admin-Server."""
print(f"Starte Admin-Interface auf http://{host}:{port}")
# Die Flask-App wird im 'admin' Modul definiert
admin.app.run(debug=True, host=host, port=port)
def main():
parser = argparse.ArgumentParser(description="Forgejo Blog Manager CLI Tool.")
parser.add_argument('action', choices=['setup', 'start'], help="Aktion: setup oder start")
args = parser.parse_args()
if args.action == 'setup':
setup_environment()
elif args.action == 'start':
start_server()
if __name__ == '__main__':
main()