Skip to content

Commit

Permalink
Implement basic inventory display commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
synkd committed Feb 14, 2024
1 parent c90ee62 commit c97cc7b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions manifester/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,18 @@ def get_manifest(manifest_category, allocation_name):
@click.option("--details", is_flag=True, help="Display full inventory details")
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:
logger.info("Displaying local inventory data")
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:
logger.info("Displaying detailed local inventory data")
for num, allocation in enumerate(inv):
click.echo(f"{num}:")
for key, value in allocation.items():
click.echo(f"{'':<8}{key}: {value}")

0 comments on commit c97cc7b

Please sign in to comment.