Add CLI and bin entrypoint: quiet runs, refusals on stderr
This commit is contained in:
+10
-7
@@ -61,10 +61,7 @@ def install_packages(packages: Sequence[str], cwd: Path) -> None:
|
||||
"""Install runtime *packages* into the project at *cwd* via pipenv."""
|
||||
if not packages:
|
||||
return
|
||||
try:
|
||||
subprocess.run(["pipenv", "install", *packages], cwd=cwd, check=True)
|
||||
except subprocess.CalledProcessError as exc:
|
||||
raise ScaffoldError(f"pipenv install failed with exit code {exc.returncode}") from exc
|
||||
_run(["pipenv", "install", *packages], cwd)
|
||||
|
||||
|
||||
def scaffold(
|
||||
@@ -108,8 +105,14 @@ def _write_files(files: dict[str, str], target: Path) -> None:
|
||||
|
||||
|
||||
def _run(command: Sequence[str], cwd: Path) -> None:
|
||||
"""Run *command* inside *cwd*, wrapping any failure in ScaffoldError."""
|
||||
"""Run *command* quietly in *cwd*, wrapping any failure in ScaffoldError.
|
||||
|
||||
Output is captured and discarded on success; on failure the command's
|
||||
stderr is included in the refusal so the cause reaches the user.
|
||||
"""
|
||||
try:
|
||||
subprocess.run(command, cwd=cwd, check=True)
|
||||
subprocess.run(command, cwd=cwd, check=True, capture_output=True, text=True)
|
||||
except subprocess.CalledProcessError as exc:
|
||||
raise ScaffoldError(f"{' '.join(command)} failed with exit code {exc.returncode}") from exc
|
||||
detail = (exc.stderr or "").strip()
|
||||
message = f"{' '.join(command)} failed with exit code {exc.returncode}"
|
||||
raise ScaffoldError(f"{message}: {detail}" if detail else message) from exc
|
||||
|
||||
Reference in New Issue
Block a user