-
Notifications
You must be signed in to change notification settings - Fork 480
Expand file tree
/
Copy pathcli.py
More file actions
57 lines (46 loc) · 1.49 KB
/
Copy pathcli.py
File metadata and controls
57 lines (46 loc) · 1.49 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
"""
`eest` is a CLI tool that helps with routine tasks.
Invoke using `uv run eest`.
"""
import sys
import click
from .commands import clean, info
from .make.cli import make
def ensure_utf8_output() -> None:
"""
Reconfigure the standard streams to UTF-8 so output cannot crash.
The `eest` commands print Unicode characters (box drawing, emoji)
that a legacy console code page such as Windows `cp1252` cannot
encode, otherwise raising `UnicodeEncodeError` mid-command. Streams
that do not support reconfiguration (for example when output is
captured in tests) are left untouched.
"""
for stream in (sys.stdout, sys.stderr):
reconfigure = getattr(stream, "reconfigure", None)
if reconfigure is None:
continue
try:
reconfigure(encoding="utf-8")
except (OSError, ValueError):
pass
@click.group(
context_settings={
"help_option_names": ["-h", "--help"],
"max_content_width": 120,
}
)
def eest() -> None:
"""`eest` is a CLI tool that helps with routine tasks."""
ensure_utf8_output()
"""
################################
|| ||
|| Command Registration ||
|| ||
################################
Register nested commands here. For more information, see Click documentation:
https://click.palletsprojects.com/en/8.0.x/commands/#nested-handling-and-contexts
"""
eest.add_command(make)
eest.add_command(clean)
eest.add_command(info)