[cli] Use prompt helper for all y/n prompts

This commit is contained in:
derrod 2020-05-29 23:09:21 +02:00
parent 82f5adfaa4
commit df566bb28f

View file

@ -284,11 +284,11 @@ class LegendaryCLI:
if '%' in save_path or '{' in save_path: if '%' in save_path or '{' in save_path:
logger.warning('Path contains unprocessed variables, please enter the correct path manually.') logger.warning('Path contains unprocessed variables, please enter the correct path manually.')
yn = 'n' yn = False
else: else:
yn = input('Is this correct? [Y/n] ') yn = get_boolean_choice('Is this correct?')
if yn and yn.lower()[0] != 'y': if not yn:
save_path = input('Please enter the correct path (leave empty to skip): ') save_path = input('Please enter the correct path (leave empty to skip): ')
if not save_path: if not save_path:
logger.info('Empty input, skipping...') logger.info('Empty input, skipping...')
@ -323,8 +323,7 @@ class LegendaryCLI:
continue continue
if not args.yes and not args.force_download: if not args.yes and not args.force_download:
choice = input(f'Download cloud save? [Y/n]: ') if not get_boolean_choice(f'Download cloud save?'):
if choice and choice.lower()[0] != 'y':
logger.info('Not downloading...') logger.info('Not downloading...')
continue continue
@ -345,8 +344,7 @@ class LegendaryCLI:
continue continue
if not args.yes and not args.force_upload: if not args.yes and not args.force_upload:
choice = input(f'Upload local save? [Y/n]: ') if not get_boolean_choice(f'Upload local save?'):
if choice and choice.lower()[0] != 'y':
logger.info('Not uploading...') logger.info('Not uploading...')
continue continue
logger.info('Uploading local savegame...') logger.info('Uploading local savegame...')
@ -457,8 +455,7 @@ class LegendaryCLI:
if not os.path.exists(repair_file): if not os.path.exists(repair_file):
logger.info('Game has not been verified yet.') logger.info('Game has not been verified yet.')
if not args.yes: if not args.yes:
choice = input(f'Verify "{game.app_name}" now (answer "no" will abort repair)? [Y/n]: ') if not get_boolean_choice(f'Verify "{game.app_name}" now ("no" will abort repair)?'):
if choice and choice.lower()[0] != 'y':
print('Aborting...') print('Aborting...')
exit(0) exit(0)
@ -521,8 +518,7 @@ class LegendaryCLI:
'CTRL-C and resume it using the same command later on.') 'CTRL-C and resume it using the same command later on.')
if not args.yes: if not args.yes:
choice = input(f'Do you wish to install "{igame.title}"? [Y/n]: ') if not get_boolean_choice(f'Do you wish to install "{igame.title}"?'):
if choice and choice.lower()[0] != 'y':
print('Aborting...') print('Aborting...')
exit(0) exit(0)
@ -561,8 +557,7 @@ class LegendaryCLI:
install_dlcs = True install_dlcs = True
if not args.yes: if not args.yes:
choice = input(f'Do you wish to automatically install DLCs ? [Y/n]: ') if not get_boolean_choice(f'Do you wish to automatically install DLCs?'):
if choice and choice.lower()[0] != 'y':
install_dlcs = False install_dlcs = False
if install_dlcs: if install_dlcs:
@ -624,8 +619,7 @@ class LegendaryCLI:
exit(1) exit(1)
if not args.yes: if not args.yes:
choice = input(f'Do you wish to uninstall "{igame.title}"? [y/N]: ') if not get_boolean_choice(f'Do you wish to uninstall "{igame.title}"?', default=False):
if not choice or choice.lower()[0] != 'y':
print('Aborting...') print('Aborting...')
exit(0) exit(0)