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 sys
import argparse
from . import admin
# Annahme: Das Repo-Root-Verzeichnis ist das aktuelle Arbeitsverzeichnis
REPO_ROOT = os.getcwd()
def setup_environment():
"""Erstellt notwendige Verzeichnisse und initialisiert Pelican/Git-Struktur."""
print("Starte Setup...")
# 1. Sicherstellen, dass die Content-Verzeichnisse existieren
if not os.path.exists(os.path.join(REPO_ROOT, 'content')):
os.makedirs(os.path.join(REPO_ROOT, 'content'))
print(" -> 'content/' Verzeichnis erstellt.")
if not os.path.exists(os.path.join(REPO_ROOT, 'downloads')):
os.makedirs(os.path.join(REPO_ROOT, 'downloads'))
print(" -> 'downloads/' Verzeichnis erstellt.")
# 2. To-Do: Hier müsste die initiale Pelican Konfiguration
# 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()
import os
import argparse
from . import admin
def setup_environment():
print("Initialisiere Blog-Struktur...")
for folder in ['content', 'downloads']:
os.makedirs(folder, exist_ok=True)
print(f" -> {folder}/ erstellt.")
print("Setup abgeschlossen.")
def main():
parser = argparse.ArgumentParser(description="Forgejo Blog Manager CLI")
parser.add_argument('action', choices=['setup', 'start'])
args = parser.parse_args()
if args.action == 'setup':
setup_environment()
elif args.action == 'start':
admin.app.run(host='127.0.0.1', port=5000)
if __name__ == '__main__':
main()