Skip to content

Commit

Permalink
icm lsgit: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Jun 19, 2024
1 parent b5a7f79 commit 230ebfc
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions icm/commands/cmd_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""List available collections"""

import click
from icm.commons import commons


Expand Down Expand Up @@ -51,16 +52,18 @@
}


def list_collections(collection: commons.Collection, typec: str) -> None:
def list_collections(
collection: commons.Collection, typec: str, fg="white"
) -> None:
"""List all the collections of a given type
* collection: Context information
* typec: Type of collections
'stable': Estable collections
'dev' : Development collections
"""

print(f"{'Name':<15} {'Version':<8} Description")
print(f"{'-'*15:<15} {'-'*8:<8} ----------")
click.secho(f"{'Name':<15} {'Version':<8} Description", fg=fg)
click.secho(f"{''*15:<15} {''*8:<8} {'─'*20}", fg=fg)
for name in COLLECTION_STORE[typec]:

# Calculate the url for the collection package.json file
Expand All @@ -74,35 +77,36 @@ def list_collections(collection: commons.Collection, typec: str) -> None:
version = package["version"]
desc = package["description"]

print(f"* {name:<15} {version:<8} {desc}")
click.secho(f" {name:<15} {version:<8} {desc}", fg=fg)

# -- There was an error
else:
print(f"* {name:<15} {'xxx':<8} {'xxx'}")
click.secho(f" {name:<15} {'xxx':<8} {'xxx'}", fg="red")


def main():
"""ENTRY POINT: List available collections"""

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

print()

# -- Header
print("-----------------------------------------")
print("AVAILABE COLLECTIONS")
print("-----------------------------------------")
print("STABLE ")
print("--------------------------")
print()
list_collections(collection, "stable")
click.secho(ctx.line, fg="yellow")
click.secho("AVAILABLE COLLECTIONS", fg="yellow")
click.secho(ctx.line, fg="yellow")

print()
print("--------------------------")
print("DEV ")
print("--------------------------")
click.secho("─" * 50, fg="green")
click.secho("STABLE", fg="green")
click.secho("─" * 50, fg="green")
list_collections(collection, "stable", fg="green")

print()
list_collections(collection, "dev")
click.secho("─" * 50, fg="blue")
click.secho("DEV", fg="blue")
click.secho("─" * 50, fg="blue")
list_collections(collection, "dev", fg="blue")

0 comments on commit 230ebfc

Please sign in to comment.