-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
94 lines (70 loc) · 2.17 KB
/
main.py
File metadata and controls
94 lines (70 loc) · 2.17 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import getpass
import sys
import typer
from screen import render_screen, render_stats
from storage import ResultsStorage
from utils import generate_words
username = getpass.getuser()
app = typer.Typer(
help="HyperType is a CLI app that helps you improve your typing speed and accuracy.",
add_completion=False,
)
def show_help():
"""Display custom help message"""
print("""HyperType - Terminal Typing Speed Test
Commands:
hypertype start <seconds> - Start a typing test (15, 30, or 60)
Example: hypertype start 30
hypertype stats - View your statistics
hypertype --help - Show this help message
""")
def show_welcome():
"""Show welcome message"""
print(f"""Welcome to HyperType!, {username}
Practice daily • Improve speed • Boost accuracy
Features:
- 15s / 30s / 60s typing modes
- Real-time feedback
- WPM + accuracy tracking
- Daily typing exercises
Start typing. Start improving.
Commands:
hypertype start <seconds> - Start a typing test (15, 30, or 60)
Example: hypertype start 30
hypertype stats - View your statistics
hypertype --help - Show this help message
""")
@app.callback(invoke_without_command=True)
def main(ctx: typer.Context):
"""
HyperType is a CLI app that helps you improve your typing speed and accuracy.
"""
# Only show welcome if no subcommand was provided
if ctx.invoked_subcommand is None:
show_welcome()
@app.command()
def start(mode: int):
"""
Start the typing game.
Args:
mode (int): The typing mode to start (15, 30, or 60 seconds).
Returns:
None
"""
words = generate_words(mode)
current_session_response = render_screen(words, mode)
storage = ResultsStorage()
storage.save_result(current_session_response)
@app.command()
def stats():
"""Display user's stats."""
render_stats(username)
@app.command(name="help", hidden=True)
def help_command():
"""Show help message"""
show_help()
if __name__ == "__main__":
if "--help" in sys.argv or "-h" in sys.argv:
show_help()
sys.exit(0)
app()