From 9e21f166eece5a8d89e1b2fe942903f5fffe60c5 Mon Sep 17 00:00:00 2001 From: synkd Date: Wed, 14 Feb 2024 14:32:09 -0500 Subject: [PATCH] Implement basic inventory display commands. --- manifester/commands.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/manifester/commands.py b/manifester/commands.py index 1b66754..ff7efe0 100644 --- a/manifester/commands.py +++ b/manifester/commands.py @@ -39,4 +39,16 @@ def get_manifest(manifest_category, allocation_name): def inventory(details): """Display the local inventory file's contents.""" logger.info("Displaying local inventory data") - click.echo(helpers.load_inventory_file(Path(settings.inventory_path))) + inv = helpers.load_inventory_file(Path(settings.inventory_path)) + if not details: + click.echo("-" * 38) + click.echo(f"| {'Index'} | {'Allocation Name':<26} |") + click.echo("-" * 38) + for num, allocation in enumerate(inv): + click.echo(f"| {num:<5} | {allocation['name']:<26} |") + click.echo("-" * 38) + else: + for num, allocation in enumerate(inv): + click.echo(f"{num}:") + for key, value in allocation.items(): + click.echo(f"{'':<8}{key}: {value}")