Skip to content

Commit

Permalink
Add --yes option
Browse files Browse the repository at this point in the history
  • Loading branch information
msj committed Aug 21, 2023
1 parent 8fdc8d3 commit b19059d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pupa/cli/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def add_args(self):
action="store_true",
help="delete objects without getting user confirmation",
)
self.add_argument(
"--yes",
action="store_true",
help="delete objects without getting user confirmation",
)

def get_stale_objects(self, window):
"""
Expand Down Expand Up @@ -94,11 +99,12 @@ def handle(self, args, other):
if args.noinput:
# Fail-safe to avoid deleting a large amount of objects
# without explicit confimation
if num_stale_objects > 10:
if num_stale_objects > 10 and not args.yes:
print(
f"This command would delete {num_stale_objects} objects: "
f"\n{stale_objects}"
"\nIf you're sure, re-run without --noinput to provide confirmation."
"\nOr re-run with --yes to assume a yes answer to all prompts."
)
sys.exit(1)
else:
Expand Down

0 comments on commit b19059d

Please sign in to comment.