Skip to content

Commit

Permalink
Merge pull request #48 from synkd/accept_token_as_arg_for_cli_delete
Browse files Browse the repository at this point in the history
Accept offline token option for CLI delete command
  • Loading branch information
synkd authored Sep 11, 2024
2 parents b53f403 + 7e0ff17 commit 5821185
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions manifester/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ def get_manifest(manifest_category, allocation_name, requester):
default=False,
help="Delete local manifest files in addition to upstream subscription allocations",
)
def delete(allocations, all_, remove_manifest_file):
@click.option("--offline-token", type=str, default=None)
def delete(allocations, all_, remove_manifest_file, offline_token):
"""Delete subscription allocations in inventory and optionally delete local manifest files."""
inv = helpers.load_inventory_file(Path(settings.inventory_path))
for num, allocation in enumerate(inv):
if str(num) in allocations or allocation.get("name") in allocations or all_:
Manifester(minimal_init=True).delete_subscription_allocation(
uuid=allocation.get("uuid")
)
Manifester(
minimal_init=True, offline_token=offline_token
).delete_subscription_allocation(uuid=allocation.get("uuid"))
if remove_manifest_file:
manifester_directory = (
Path(os.environ["MANIFESTER_DIRECTORY"]).resolve()
Expand All @@ -78,7 +79,9 @@ def inventory(details, sync, offline_token):
"""Display the local inventory file's contents."""
border = "-" * 38
if sync:
helpers.update_inventory(Manifester(minimal_init=True, offline_token=offline_token).subscription_allocations)
helpers.update_inventory(
Manifester(minimal_init=True, offline_token=offline_token).subscription_allocations
)
inv = helpers.load_inventory_file(Path(settings.inventory_path))
if not details:
logger.info("Displaying local inventory data")
Expand Down

0 comments on commit 5821185

Please sign in to comment.