Skip to content

Commit

Permalink
icm info: Folders: Add check method
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Jun 17, 2024
1 parent cf6dcb1 commit 5692da8
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions icm/commands/cmd_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def collections(self) -> Path:
"""Return the icestudio collections folder"""
return self.icestudio / "collections"

@staticmethod
def check(folder: Path) -> str:
"""Return a check character depending if the folder exists
✅ : Folder exists
❌ : Folder does NOT exist
"""
return "✅ " if folder.exists() else "❌ "


# -- Information about collections
icek = {"name": "iceK", "version": "0.1.4"}
Expand Down Expand Up @@ -95,27 +103,17 @@ def print_folders_info(ctx: Context, folders: Folders) -> None:
click.secho("FOLDERS", fg="yellow")
click.secho(ctx.line, fg="yellow")

# -- Check if all the folders exist or not
ok_home = folders.home.exists()
ok_icestudio = folders.icestudio.exists()
ok_collections = folders.collections.exists()

# -- Choose the correct bullet for the folder
home_check = "✅ " if ok_home else "❌ "
icestudio_check = "✅ " if ok_icestudio else "❌ "
collections_check = "✅ " if ok_collections else "❌ "

# -- Print the information
click.echo(
home_check + click.style("HOME: ", fg="yellow") + f"{folders.home}"
folders.check(folders.home) + click.style("HOME: ", fg="yellow") + f"{folders.home}"
)
click.echo(
icestudio_check
folders.check(folders.icestudio)
+ click.style("Icestudio: ", fg="yellow")
+ f"{folders.icestudio}"
)
click.echo(
collections_check
folders.check(folders.collections)
+ click.style("Collections: ", fg="yellow")
+ f"{folders.collections}"
)
Expand Down

0 comments on commit 5692da8

Please sign in to comment.