diff options
| author | main <main@swarm.moe> | 2026-03-19 15:49:41 -0400 |
|---|---|---|
| committer | main <main@swarm.moe> | 2026-03-19 15:49:41 -0400 |
| commit | fa1bd32800b65aab31ea732dd240261b4047522c (patch) | |
| tree | 2fd08af6f36b8beb3c7c941990becc1a0a091d62 /check.py | |
| download | adequate-rust-mcp-fa1bd32800b65aab31ea732dd240261b4047522c.zip | |
Release adequate-rust-mcp 1.0.0v1.0.0
Diffstat (limited to 'check.py')
| -rwxr-xr-x | check.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/check.py b/check.py new file mode 100755 index 0000000..2b33dbf --- /dev/null +++ b/check.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import subprocess +import tomllib +from pathlib import Path + +ROOT = Path(__file__).resolve().parent +WORKSPACE_MANIFEST = ROOT / "Cargo.toml" +DEFAULT_CLIPPY = ["cargo", "clippy", "--workspace", "--all-targets", "--all-features"] + + +def run(argv: list[str]) -> None: + print("+", " ".join(argv), flush=True) + proc = subprocess.run(argv, cwd=ROOT) + if proc.returncode != 0: + raise SystemExit(proc.returncode) + + +def normalized_clippy_command() -> list[str]: + workspace = tomllib.loads(WORKSPACE_MANIFEST.read_text(encoding="utf-8")) + metadata = ( + workspace.get("workspace", {}) + .get("metadata", {}) + .get("adequate-rust-mcp", {}) + ) + configured = metadata.get("clippy_command") + if not ( + isinstance(configured, list) + and configured + and all(isinstance(part, str) for part in configured) + ): + return DEFAULT_CLIPPY + + # Human check output does not need machine JSON framing. + command: list[str] = [] + skip_next = False + for index, part in enumerate(configured): + if skip_next: + skip_next = False + continue + if part.startswith("--message-format="): + continue + if part == "--message-format" and index + 1 < len(configured): + skip_next = True + continue + command.append(part) + return command or DEFAULT_CLIPPY + + +def main() -> None: + run(["cargo", "fmt", "--all", "--check"]) + run(normalized_clippy_command()) + run(["cargo", "test", "--workspace", "--all-targets", "--all-features"]) + + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + raise SystemExit(130) |