Skip to content

Commit

Permalink
Added overwrite option to cli, for simpler automation (#9)
Browse files Browse the repository at this point in the history
* Added overwrite option to cli, for simpler automation

* Fix the cli documentation comments

* Updated the doc message for overwrite
  • Loading branch information
nicolas-schreiber authored Jul 25, 2022
1 parent 39e9f2b commit 868331d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ optional arguments:
--save-mjcf save an example XML (MJCF) file
--compile-model compile the MJCF file to check for errors
--verbose print verbose output
--overwrite overwrite previous run output

optional vhacd_args arguments:
arguments to pass to V-HACD
Expand Down
15 changes: 9 additions & 6 deletions obj2mjcf/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class Args:
vhacd_args: VhacdArgs = field(default_factory=VhacdArgs)
"""arguments to pass to V-HACD"""
texture_args: TextureArgs = field(default_factory=TextureArgs)
overwrite: bool = False
"""overwrite previous run output"""


@dataclass
Expand Down Expand Up @@ -249,12 +251,13 @@ def process_obj(filename: Path, args: Args) -> None:
# and materials will be stored there.
work_dir = filename.parent / filename.stem
if work_dir.exists():
proceed = input(
f"{work_dir.resolve()} already exists, maybe from a previous run? "
"Proceeding will overwrite it.\nDo you wish to continue [y/n]: "
)
if proceed.lower() != "y":
return
if not args.overwrite:
proceed = input(
f"{work_dir.resolve()} already exists, maybe from a previous run? "
"Proceeding will overwrite it.\nDo you wish to continue [y/n]: "
)
if proceed.lower() != "y":
return
shutil.rmtree(work_dir)
work_dir.mkdir(exist_ok=True)
logging.info(f"Saving processed meshes to {work_dir}")
Expand Down

0 comments on commit 868331d

Please sign in to comment.