src/dlw/commands.py aktualisiert
This commit is contained in:
parent
fef09ead53
commit
83feeb6a64
|
|
@ -1,47 +1,23 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import argparse
|
import argparse
|
||||||
from . import admin
|
from . import admin
|
||||||
|
|
||||||
# Annahme: Das Repo-Root-Verzeichnis ist das aktuelle Arbeitsverzeichnis
|
|
||||||
REPO_ROOT = os.getcwd()
|
|
||||||
|
|
||||||
def setup_environment():
|
def setup_environment():
|
||||||
"""Erstellt notwendige Verzeichnisse und initialisiert Pelican/Git-Struktur."""
|
print("Initialisiere Blog-Struktur...")
|
||||||
print("Starte Setup...")
|
for folder in ['content', 'downloads']:
|
||||||
|
os.makedirs(folder, exist_ok=True)
|
||||||
# 1. Sicherstellen, dass die Content-Verzeichnisse existieren
|
print(f" -> {folder}/ erstellt.")
|
||||||
if not os.path.exists(os.path.join(REPO_ROOT, 'content')):
|
print("Setup abgeschlossen.")
|
||||||
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():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Forgejo Blog Manager CLI Tool.")
|
parser = argparse.ArgumentParser(description="Forgejo Blog Manager CLI")
|
||||||
parser.add_argument('action', choices=['setup', 'start'], help="Aktion: setup oder start")
|
parser.add_argument('action', choices=['setup', 'start'])
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.action == 'setup':
|
if args.action == 'setup':
|
||||||
setup_environment()
|
setup_environment()
|
||||||
elif args.action == 'start':
|
elif args.action == 'start':
|
||||||
start_server()
|
admin.app.run(host='127.0.0.1', port=5000)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue