refactor(clew): rename force flag to overwrite
This commit is contained in:
@@ -31,7 +31,7 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
|
|||||||
help="Output root. Defaults to repository output/.",
|
help="Output root. Defaults to repository output/.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--force",
|
"--overwrite",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Replace Clew-managed output directories.",
|
help="Replace Clew-managed output directories.",
|
||||||
)
|
)
|
||||||
@@ -54,13 +54,13 @@ def resolve_output_root(output_root: Path) -> Path:
|
|||||||
return output_root.resolve()
|
return output_root.resolve()
|
||||||
|
|
||||||
|
|
||||||
def prepare_output(output_root: Path, force: bool) -> tuple[Path, Path]:
|
def prepare_output(output_root: Path, overwrite: 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 overwrite:
|
||||||
raise SystemExit(f"clew: refusing to overwrite existing output path: {path}")
|
raise SystemExit(f"clew: refusing to overwrite existing output path: {path}")
|
||||||
|
|
||||||
if force:
|
if overwrite:
|
||||||
for name in MANAGED_DIRS:
|
for name in MANAGED_DIRS:
|
||||||
shutil.rmtree(output_root / name, ignore_errors=True)
|
shutil.rmtree(output_root / name, ignore_errors=True)
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ def run(args: argparse.Namespace) -> None:
|
|||||||
raise SystemExit(f"clew: 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.overwrite)
|
||||||
configure_logging(logs_dir)
|
configure_logging(logs_dir)
|
||||||
|
|
||||||
LOGGER.info("copying loose files")
|
LOGGER.info("copying loose files")
|
||||||
|
|||||||
Reference in New Issue
Block a user