#!/usr/bin/env python3 from core import temperature_logger as temp PROMPT = "> " SHORT_HINT = "h = Hilfe" VERSION = "v1.0.0" def print_short_banner(): print("Temperatur-Logger " + VERSION) print("Mit 'h' Hilfe anzeigen.\n") def print_help(): print(""" VERFÜGBARE BEFEHLE ------------------ start | s Logger starten stop | p Logger stoppen reset | r Messwerte zurücksetzen interval | i Messintervall setzen status | t Status anzeigen help | h Diese Hilfe anzeigen exit | x Programm beenden """) def handle_interval(cmd: str): parts = cmd.split() if len(parts) == 2 and parts[1].isdigit(): temp.set_interval(int(parts[1])) print("OK") else: print("Verwendung: interval ") def handle_status(): state = "RUNNING" if temp.running else "STOPPED" print(f"STATUS : {state}") print(f"INTERVALL: {temp.INTERVAL}") def main(): print_short_banner() while True: try: cmd = input(PROMPT).strip().lower() except (EOFError, KeyboardInterrupt): print() temp.stop() break if not cmd: continue if cmd in ("start", "s"): temp.start() elif cmd in ("stop", "p"): temp.stop() elif cmd in ("reset", "r"): temp.reset() elif cmd.startswith("interval") or cmd.startswith("i "): handle_interval(cmd) elif cmd in ("status", "t"): handle_status() elif cmd in ("help", "h"): print_help() elif cmd in ("exit", "x"): temp.stop() break else: print(f"Unbekannter Befehl ({SHORT_HINT})") if __name__ == "__main__": main()