-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmd_cli.py
More file actions
31 lines (23 loc) · 901 Bytes
/
tmd_cli.py
File metadata and controls
31 lines (23 loc) · 901 Bytes
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
#!/usr/bin/env python3
"""TMD Command-Line Interface (wrapper around ``tmd.cli.main``)."""
import sys
def _reconfigure_stdio_utf8() -> None:
"""Avoid Rich/Windows cp1252 Unicode errors (spinners, checkmarks) on teardown."""
if sys.platform != "win32":
return
for stream in (getattr(sys, "stdout", None), getattr(sys, "stderr", None)):
if stream is not None and hasattr(stream, "reconfigure"):
try:
stream.reconfigure(encoding="utf-8", errors="replace")
except OSError:
pass
_reconfigure_stdio_utf8()
try:
from tmd.cli.main import main
except ImportError as e:
from rich.console import Console
Console().print(f"[red]Error importing TMD modules: {e}[/red]")
Console().print("[yellow]Make sure TMD is properly installed[/yellow]")
sys.exit(1)
if __name__ == "__main__":
sys.exit(main())