Skip to content

Commit b45011c

Browse files
committed
Update precommit output styles
1 parent 5e75a0d commit b45011c

File tree

1 file changed

+40
-12
lines changed
  • plain-dev/plain/dev/precommit

1 file changed

+40
-12
lines changed

plain-dev/plain/dev/precommit/cli.py

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,51 +46,79 @@ def cli(install: bool) -> None:
4646
.get("run", {})
4747
).items():
4848
cmd = data["cmd"]
49-
print_event(f"Custom: {name} -> {cmd}")
49+
print_event(
50+
click.style(f"Custom[{name}]:", bold=True)
51+
+ click.style(f" {cmd}", dim=True),
52+
newline=False,
53+
)
5054
result = subprocess.run(cmd, shell=True)
5155
if result.returncode != 0:
5256
sys.exit(result.returncode)
5357

5458
# Run this first since it's probably the most likely to fail
5559
if find_spec("plain.code"):
56-
check_short("Running plain code checks", "plain", "code", "check")
60+
check_short(
61+
click.style("Code:", bold=True)
62+
+ click.style(" plain code check", dim=True),
63+
"plain",
64+
"code",
65+
"check",
66+
)
5767

5868
if Path("uv.lock").exists():
59-
check_short("Checking uv.lock", "uv", "lock", "--check")
69+
check_short(
70+
click.style("Dependencies:", bold=True)
71+
+ click.style(" uv lock --check", dim=True),
72+
"uv",
73+
"lock",
74+
"--check",
75+
)
6076

6177
if plain_db_connected():
6278
check_short(
63-
"Running preflight checks",
79+
click.style("Preflight:", bold=True)
80+
+ click.style(" plain preflight check", dim=True),
6481
"plain",
6582
"preflight",
6683
"check",
6784
"--quiet",
6885
)
69-
check_short("Checking Plain migrations", "plain", "migrate", "--check")
7086
check_short(
71-
"Checking for Plain models missing migrations",
87+
click.style("Migrate:", bold=True)
88+
+ click.style(" plain migrate --check", dim=True),
89+
"plain",
90+
"migrate",
91+
"--check",
92+
)
93+
check_short(
94+
click.style("Migrations:", bold=True)
95+
+ click.style(" plain makemigrations --dry-run --check", dim=True),
7296
"plain",
7397
"makemigrations",
7498
"--dry-run",
7599
"--check",
76100
)
77101
else:
78102
check_short(
79-
"Running Plain checks (without database)",
103+
click.style("Preflight:", bold=True)
104+
+ click.style(" plain preflight check", dim=True),
80105
"plain",
81106
"preflight",
82107
"check",
83108
"--quiet",
84109
)
85110
click.secho("--> Skipping migration checks", bold=True, fg="yellow")
86111

87-
print_event("Running plain build")
88-
result = subprocess.run(["plain", "build"])
89-
if result.returncode != 0:
90-
sys.exit(result.returncode)
112+
check_short(
113+
click.style("Build:", bold=True) + click.style(" plain build", dim=True),
114+
"plain",
115+
"build",
116+
)
91117

92118
if find_spec("plain.pytest"):
93-
print_event("Running tests")
119+
print_event(
120+
click.style("Test:", bold=True) + click.style(" plain test", dim=True)
121+
)
94122
result = subprocess.run(["plain", "test"])
95123
if result.returncode != 0:
96124
sys.exit(result.returncode)

0 commit comments

Comments
 (0)