Skip to content

Commit bf8bf3b

Browse files
committed
Support Click 8.2+
Click 8.2 and above will now force an abort if a confirmation prompt isn't answered, rather than raising the CLIAbort that is expected. Catch this exception so that our own exceptions are raised.
1 parent 85255be commit bf8bf3b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

SoftLayer/CLI/formatting.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ def confirm(prompt_str, default=False):
243243
default_str = 'n'
244244
prompt = '%s [y/N]' % prompt_str
245245

246-
ans = click.prompt(prompt, default=default_str, show_default=False)
246+
try:
247+
ans = click.prompt(prompt, default=default_str, show_default=False)
248+
except click.exceptions.Abort:
249+
return False
247250
if ans.lower() in ('y', 'yes', 'yeah', 'yup', 'yolo'):
248251
return True
249252

@@ -260,7 +263,10 @@ def no_going_back(confirmation):
260263

261264
prompt = f"This action cannot be undone! Type '{confirmation}' or press Enter to abort"
262265

263-
ans = click.prompt(prompt, default='', show_default=False)
266+
try:
267+
ans = click.prompt(prompt, default='', show_default=False)
268+
except click.exceptions.Abort:
269+
return False
264270
if ans.lower() == str(confirmation).lower():
265271
return True
266272

0 commit comments

Comments
 (0)