refactor(clew): inline process exits

This commit is contained in:
2026-09-07 14:28:29 -04:00
parent 16ca280959
commit 48bd0cd374

View File

@@ -43,10 +43,6 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
return parser.parse_args(argv) return parser.parse_args(argv)
def fail(message: str) -> None:
raise SystemExit(f"clew: {message}")
def resolve_output_root(output_root: Path) -> Path: def resolve_output_root(output_root: Path) -> Path:
if output_root.is_absolute(): if output_root.is_absolute():
return output_root.resolve() return output_root.resolve()
@@ -62,7 +58,7 @@ def prepare_output(output_root: Path, force: bool) -> tuple[Path, Path]:
for name in MANAGED_DIRS: for name in MANAGED_DIRS:
path = output_root / name path = output_root / name
if path.exists() and not force: if path.exists() and not force:
fail(f"refusing to overwrite existing output path: {path}") raise SystemExit(f"clew: refusing to overwrite existing output path: {path}")
if force: if force:
for name in MANAGED_DIRS: for name in MANAGED_DIRS:
@@ -87,7 +83,7 @@ def normalize_suffixes(suffixes: list[str] | None) -> list[str] | None:
normalized = [] normalized = []
for suffix in suffixes: for suffix in suffixes:
if not suffix: if not suffix:
fail("suffix must not be empty") raise SystemExit("clew: suffix must not be empty")
if not suffix.startswith("."): if not suffix.startswith("."):
suffix = f".{suffix}" suffix = f".{suffix}"
normalized.append(suffix) normalized.append(suffix)
@@ -136,7 +132,7 @@ def run(args: argparse.Namespace) -> None:
output_root = resolve_output_root(args.output_root) output_root = resolve_output_root(args.output_root)
if not game_root.is_dir(): if not game_root.is_dir():
fail(f"game root is not a directory: {game_root}") raise SystemExit(f"clew: game root is not a directory: {game_root}")
suffixes = normalize_suffixes(args.suffix) suffixes = normalize_suffixes(args.suffix)
extracted_dir, logs_dir = prepare_output(output_root, args.force) extracted_dir, logs_dir = prepare_output(output_root, args.force)