Skip to content

Commit

Permalink
Dev Env's assigned tasks are printed with the info command.
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmurai committed Apr 30, 2024
1 parent 7b0633c commit 3cbce65
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 141 deletions.
72 changes: 53 additions & 19 deletions dem/cli/command/info_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,68 @@
ToolImage.LOCAL_AND_REGISTRY: "Local and Registry",
}

def print_local_dev_env_info(platform: Platform, dev_env: DevEnv) -> None:
""" Print information about the given local Development Environment.
def print_status(platform: Platform, dev_env: DevEnv) -> None:
""" Print the status of the Development Environment.
Args:
dev_env -- the Development Environment to print information about
platform -- the platform
dev_env -- the Development Environment to print the status of
"""
tool_info_table = Table()
tool_info_table.add_column("Image")
tool_info_table.add_column("Availability")

for tool_image in sorted(dev_env.tool_images, key=lambda x: x.name):
tool_info_table.add_row(tool_image.name,
image_status_messages[tool_image.availability])
if dev_env.is_installed:
status = "[green]Installed[/]"
if dev_env.name == platform.default_dev_env_name:
status = status.replace("[/]", " | Default[/]")
else:
status = "Not installed"
stdout.print(f"\n[bold]Development Environment: {dev_env.name}[/]\n")

stdout.print(f"Status: {status}\n")

def print_tools_info_table(dev_env: DevEnv, is_local: bool, platform: Platform = None) -> None:
""" Print information about the tools in the Development Environment.
Args:
dev_env -- the Development Environment to print information about
is_local -- flag to indicate if the Development Environment is local
platform -- the platform (only needed if is_local is True)
"""
tool_info_table = Table(title="Tools")
tool_info_table.add_column("Image")
tool_info_table.add_column("Availability")

for tool_image in sorted(dev_env.tool_images, key=lambda x: x.name):
tool_info_table.add_row(tool_image.name,
image_status_messages[tool_image.availability])
if is_local:
print_status(platform, dev_env)
stdout.print(tool_info_table)

def print_tasks_info_table(dev_env: DevEnv) -> None:
""" Print information about the tasks in the Development Environment.
Args:
dev_env -- the Development Environment to print information about
"""
task_table = Table(title="Tasks")
task_table.add_column("Task")
task_table.add_column("Command")

for task_name, command in dev_env.tasks.items():
task_table.add_row(task_name, command)

stdout.print(task_table)

def print_local_dev_env_info(platform: Platform, dev_env: DevEnv) -> None:
""" Print information about the given local Development Environment.
Args:
platform -- the platform
dev_env -- the Development Environment to print information about
"""
stdout.print(f"\n[bold]Development Environment: {dev_env.name}[/]\n")
print_tools_info_table(dev_env, True, platform)
if dev_env.tasks:
print_tasks_info_table(dev_env)

if dev_env.is_installed and dev_env.get_tool_image_status() == DevEnv.Status.REINSTALL_NEEDED:
stderr.print("\n[red]Error: Incomplete local install! The Dev Env must be reinstalled![/]")

Expand Down Expand Up @@ -71,16 +110,11 @@ def print_cat_dev_env_info(dev_env: DevEnv, cat_name: str) -> None:
dev_env -- the Development Environment to print information about
cat_name -- the name of the catalog the Development Environment belongs to
"""
tool_info_table = Table()
tool_info_table.add_column("Image")
tool_info_table.add_column("Availability")

for tool_image in sorted(dev_env.tool_images, key=lambda x: x.name):
tool_info_table.add_row(tool_image.name,
image_status_messages[tool_image.availability])
stdout.print(f"\n[bold]Development Environment: {dev_env.name}[/]\n")
stdout.print(f"Catalog: {cat_name}\n")
stdout.print(tool_info_table)
print_tools_info_table(dev_env, False)
if dev_env.tasks:
print_tasks_info_table(dev_env)

if dev_env.get_tool_image_status() == DevEnv.Status.UNAVAILABLE_IMAGE:
stderr.print("\n[red]Error: Required image could not be found in the registry![/]")
Expand Down
Loading

0 comments on commit 3cbce65

Please sign in to comment.