inwx-api-tool/inwx_cli.py

66 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import getpass
from inwx_config import login, logout # Importiere Login/Logout aus der Konfigurationsdatei
from inwx_dns_functions import get_dns_info, add_record, update_record, delete_record # Importiere DNS-Funktionen
# 1. Login-Daten abfragen (kann auch über Umgebungsvariablen INWX_USER/INWX_PASS gesetzt werden)
def main_menu():
"""Hauptmenü der CLI-Anwendung."""
# 1. Login-Daten abfragen
INWX_USER = os.getenv('INWX_USER')
INWX_PASS = os.getenv('INWX_PASS')
if not INWX_USER:
INWX_USER = input("Gib deinen INWX-Benutzernamen ein: ")
if not INWX_PASS:
# **WICHTIGE KORREKTUR HIER:** Verwende getpass.getpass()
INWX_PASS = getpass.getpass("Gib dein INWX-Passwort ein: ")
if not login(INWX_USER, INWX_PASS):
return
# 2. Hauptschleife
try:
while True:
# Das Menü im MC-Stil
print("\n" + "=" * 40)
print(" INWX DNS-CLI (MC-Style) - DOMAIN-VERWALTUNG")
print("=" * 40)
print("1: 🌐 **Anzeigen** (nameserver.info)")
print("---")
print("2: **Hinzufügen** (nameserver.addRecord)")
print("3: ✏️ **Ändern** (nameserver.updateRecord)")
print("4: 🗑️ **Löschen** (nameserver.deleteRecord)")
print("---")
print("9: 🚪 Logout & Beenden")
print("-" * 40)
choice = input("Wähle eine Aktion (1-4 oder 9): ").strip()
if choice == '1':
domain = input("Gib die Domain ein, deren Einträge du sehen möchtest: ").strip()
if domain:
get_dns_info(domain)
elif choice == '2':
add_record()
elif choice == '3':
update_record()
elif choice == '4':
delete_record()
elif choice == '9':
break
else:
print("Ungültige Auswahl. Bitte versuche es erneut.")
finally:
# Stelle sicher, dass immer ausgeloggt wird
logout()
if __name__ == "__main__":
main_menu()