Skip to content

Commit

Permalink
icm rm: add option --yes
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Jun 26, 2024
1 parent 2af015d commit c637037
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions icm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ def ls():

@cli.command()
@click.argument("collection", nargs=1)
def rm(collection):
@click.option("-y", "--yes", is_flag=True, help="Respond yes automatically")
def rm(collection, yes):
"""Remove colections"""

cmd_rm.main(collection)
cmd_rm.main(collection, yes)


@cli.command()
Expand Down
5 changes: 3 additions & 2 deletions icm/commands/cmd_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from icm.commons import commons


def main(coltag: str) -> None:
def main(coltag: str, yes: bool) -> None:
"""ENTRY POINT: Remove collections
* coltag: Name+version of the collection to remove
(Ex. iceK-0.1.4)
* yes: Respond "yes" automatically
"""

# -- Get context information
Expand Down Expand Up @@ -63,7 +64,7 @@ def main(coltag: str) -> None:
abs_collection = folders.collections / coltag

# -- Ask for confirmation!
if click.confirm(f"{coltag}: Remove?"):
if yes or click.confirm(f"{coltag}: Remove?"):
# -- Remove the collection!
shutil.rmtree(abs_collection)
return
Expand Down

0 comments on commit c637037

Please sign in to comment.