aboutsummaryrefslogtreecommitdiffstats
path: root/egometrics.py
blob: 87bd0b86dae13145d12da153f27cac519239522b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sqlite3

from db import get_connection, init_db
from screens import (
    log_weight,
    log_workout,
    manage_workout_exercises,
    manage_workout_templates,
    view_weight_logs,
    view_workout_sessions,
)


def main_menu(conn: sqlite3.Connection) -> None:
    import ui

    while True:
        ui.clear_screen()
        print("=== EgoMetrics ===\n")
        print("0. Quit\n")

        print("=== Workout ===\n")
        print("1. Log Session")
        print("2. View Sessions Logs")
        print("3. Manage Exercises")
        print("4. Manage Session Templates\n")

        print("=== Weight ===\n")
        print("5. Log Weight")
        print("6. View Weight Logs")

        choice = input("\n> ").strip()
        if choice == "0":
            break
        if choice == "1":
            log_workout(conn)
        elif choice == "2":
            view_workout_sessions(conn)
        elif choice == "3":
            manage_workout_exercises(conn)
        elif choice == "4":
            manage_workout_templates(conn)
        elif choice == "5":
            log_weight(conn)
        elif choice == "6":
            view_weight_logs(conn)


def main() -> None:
    init_db()
    conn = get_connection()
    try:
        main_menu(conn)
    except KeyboardInterrupt:
        print("\nGoodbye!")
    finally:
        conn.close()


if __name__ == "__main__":
    main()