aboutsummaryrefslogtreecommitdiffstats
path: root/egometrics.py
blob: f45fa6d25dc9c0b43dd9db9bf150e777b120d786 (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
import sqlite3

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


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

    while True:
        ui.clear_screen()
        print("=== EgoMetrics ===\n")
        print("1. Log Workout")
        print("2. View Workout Sessions")
        print("3. Manage Workout Exercises")
        print("4. Manage Workout Templates")
        print("5. Quit")
        choice = input("\n> ").strip()
        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":
            break


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


if __name__ == "__main__":
    main()