Skip to content

Commit

Permalink
icm rm: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Jun 26, 2024
1 parent c637037 commit ad2d0f1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion icm/commands/cmd_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,26 @@ def main(coltag: str, yes: bool) -> None:
collection = commons.Collection(folders)
print()

# -- Build the Path to the collection
# -- Remove the collection!
rm_collection(collection, folders, coltag, yes)



def rm_collection(
collection: commons.Collection,
folders: commons.Folders,
coltag: str,
yes: bool = False
) -> None:
"""Remove one collection
* collection: Context information,
* folders: Context information,
* coltag: Name+version of the collection to remove
(Ex. iceK-0.1.4)
* yes: Respond "yes" automatically
"""

# -- Build the Path to the collection
abs_collection = folders.collections / coltag

# -- Check if the collection exists, as it was typed bye the user
Expand Down Expand Up @@ -67,6 +86,7 @@ def main(coltag: str, yes: bool) -> None:
if yes or click.confirm(f"{coltag}: Remove?"):
# -- Remove the collection!
shutil.rmtree(abs_collection)
print(f" {coltag} removed!")
return

print("Aborted.")

0 comments on commit ad2d0f1

Please sign in to comment.