Skip to content

Commit

Permalink
icm rm: initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Jun 19, 2024
1 parent 297fb5a commit 8467cd8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@
"justMyCode": true,
"internalConsoleOptions": "neverOpen",
"preLaunchTask": "Clear terminal",
},
{
"name": "ICM rm",
"type": "debugpy",
"request": "launch",
"program": "icm-run.py",
"args": ["rm","iceK-0.1.3"],
//"console": "internalConsole",
"console": "integratedTerminal",
"justMyCode": true,
"internalConsoleOptions": "neverOpen",
"preLaunchTask": "Clear terminal",
}
]
}
Expand Down
9 changes: 9 additions & 0 deletions icm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
cmd_info,
cmd_install,
cmd_ls,
cmd_rm,
)


Expand Down Expand Up @@ -64,3 +65,11 @@ def ls():
"""List installed collections"""

cmd_ls.main()


@cli.command()
@click.argument("collection", nargs=1)
def rm(collection):
"""Remove colections"""

cmd_rm.main(collection)
26 changes: 26 additions & 0 deletions icm/commands/cmd_rm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Remove installed collections"""

import shutil
from icm.commons import commons


def main(name: str) -> None:
"""ENTRY POINT: Remove collections
* name: Name of the collection to remove
"""

# -- Get context information
# ctx = commons.Context()
folders = commons.Folders()
print()

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

# -- Check if the collection exists, as it was type byte the user
if not abs_collection.exists():
print(f"rm: cannot remove {name}: No such collection")
return

# -- Remove the collection folder, along with all its files
shutil.rmtree(abs_collection)

0 comments on commit 8467cd8

Please sign in to comment.