refactor(clew): inline process exits
This commit is contained in:
@@ -43,10 +43,6 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
def fail(message: str) -> None:
|
||||
raise SystemExit(f"clew: {message}")
|
||||
|
||||
|
||||
def resolve_output_root(output_root: Path) -> Path:
|
||||
if output_root.is_absolute():
|
||||
return output_root.resolve()
|
||||
@@ -62,7 +58,7 @@ def prepare_output(output_root: Path, force: bool) -> tuple[Path, Path]:
|
||||
for name in MANAGED_DIRS:
|
||||
path = output_root / name
|
||||
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:
|
||||
for name in MANAGED_DIRS:
|
||||
@@ -87,7 +83,7 @@ def normalize_suffixes(suffixes: list[str] | None) -> list[str] | None:
|
||||
normalized = []
|
||||
for suffix in suffixes:
|
||||
if not suffix:
|
||||
fail("suffix must not be empty")
|
||||
raise SystemExit("clew: suffix must not be empty")
|
||||
if not suffix.startswith("."):
|
||||
suffix = f".{suffix}"
|
||||
normalized.append(suffix)
|
||||
@@ -136,7 +132,7 @@ def run(args: argparse.Namespace) -> None:
|
||||
output_root = resolve_output_root(args.output_root)
|
||||
|
||||
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)
|
||||
extracted_dir, logs_dir = prepare_output(output_root, args.force)
|
||||
|
||||
Reference in New Issue
Block a user