[cli] Add crossover parameters to skip interactive selection

This commit is contained in:
derrod 2021-12-31 14:48:08 +01:00
parent 2e6335bf09
commit 9469d3cb6f

View file

@ -2105,6 +2105,13 @@ class LegendaryCLI:
self.core.lgd.config.remove_option(app_name, 'crossover_bottle') self.core.lgd.config.remove_option(app_name, 'crossover_bottle')
return return
if args.crossover_app:
cx_version = mac_get_crossover_version(args.crossover_app)
if not cx_version:
logger.error(f'No valid CrossOver install specified!')
return
logger.info(f'Using CrossOver {cx_version} at {args.crossover_app}')
else:
logger.info('Looking for CrossOver installs...') logger.info('Looking for CrossOver installs...')
apps = mac_find_crossover_apps() apps = mac_find_crossover_apps()
if len(apps) > 1: if len(apps) > 1:
@ -2128,7 +2135,13 @@ class LegendaryCLI:
forced_selection = None forced_selection = None
bottles = mac_get_crossover_bottles() bottles = mac_get_crossover_bottles()
if 'Legendary' not in bottles and not args.download: if args.crossover_bottle:
if args.crossover_bottle not in bottles:
logger.error(f'No valid CrossOver bottle specified!')
return
logger.info(f'Using Bottle "{args.crossover_bottle}"')
forced_selection = args.crossover_bottle
elif 'Legendary' not in bottles and not args.download:
logger.info('It is recommended to set up a bottle specifically for Legendary, see ' logger.info('It is recommended to set up a bottle specifically for Legendary, see '
'https://legendary.gl/crossover-setup for setup instructions.') 'https://legendary.gl/crossover-setup for setup instructions.')
elif args.download: elif args.download:
@ -2257,6 +2270,7 @@ class LegendaryCLI:
if y_n: if y_n:
self.core.lgd.config.set(app_name, 'crossover_app', args.crossover_app) self.core.lgd.config.set(app_name, 'crossover_app', args.crossover_app)
self.core.lgd.config.set(app_name, 'crossover_bottle', args.crossover_bottle) self.core.lgd.config.set(app_name, 'crossover_bottle', args.crossover_bottle)
logger.info('Saved choices to configuration.')
def main(): def main():
@ -2601,6 +2615,10 @@ def main():
help='Reset default/app-specific crossover configuration') help='Reset default/app-specific crossover configuration')
cx_parser.add_argument('--download', dest='download', action='store_true', cx_parser.add_argument('--download', dest='download', action='store_true',
help='Automatically download and set up a preconfigured bottle (experimental)') help='Automatically download and set up a preconfigured bottle (experimental)')
cx_parser.add_argument('--crossover-app', dest='crossover_app', action='store', metavar='<path to .app>',
help='Specify app to skip interactive selection')
cx_parser.add_argument('--crossover-bottle', dest='crossover_bottle', action='store', metavar='<bottle name>',
help='Specify bottle to skip interactive selection')
args, extra = parser.parse_known_args() args, extra = parser.parse_known_args()