[cli] Allow some eos-overlay commands to work without a prefix

This commit is contained in:
derrod 2022-06-24 12:27:24 +02:00
parent 496bda3345
commit 594e60e850

View file

@ -2093,14 +2093,6 @@ class LegendaryCLI:
args.prefix = self.core.lgd.config.get(f'{app_name}.env', 'WINEPREFIX', fallback=None) args.prefix = self.core.lgd.config.get(f'{app_name}.env', 'WINEPREFIX', fallback=None)
args.prefix = self.core.lgd.config.get(app_name, 'wine_prefix', fallback=args.prefix) args.prefix = self.core.lgd.config.get(app_name, 'wine_prefix', fallback=args.prefix)
if not args.prefix and not args.bottle:
# try using defaults if they exist
if sys_platform == 'darwin':
args.bottle = self.core.lgd.config.get('default', 'crossover_bottle', fallback=None)
args.prefix = self.core.lgd.config.get('default.env', 'WINEPREFIX', fallback=None)
args.prefix = self.core.lgd.config.get('default', 'wine_prefix', fallback=args.prefix)
if sys_platform == 'darwin' and args.bottle: if sys_platform == 'darwin' and args.bottle:
if not mac_is_valid_bottle(args.bottle): if not mac_is_valid_bottle(args.bottle):
logger.error('Invalid bottle specified.') logger.error('Invalid bottle specified.')
@ -2111,10 +2103,11 @@ class LegendaryCLI:
logger.error(f'Prefix "{args.prefix}" does not exist.') logger.error(f'Prefix "{args.prefix}" does not exist.')
return return
prefix = args.prefix prefix = args.prefix
else: elif args.action not in {'info', 'install', 'remove', 'update'}:
logger.error('Need either config default, --prefix, --bottle, or --app to install the overlay to.') logger.error('Need either --prefix, --bottle, or --app for this command.')
return return
if prefix:
if not os.path.exists(prefix): if not os.path.exists(prefix):
logger.error(f'Prefix "{prefix}" does not exist.') logger.error(f'Prefix "{prefix}" does not exist.')
return return
@ -2122,8 +2115,6 @@ class LegendaryCLI:
logger.info(f'Using prefix "{prefix}"') logger.info(f'Using prefix "{prefix}"')
if args.action == 'info': if args.action == 'info':
reg_paths = query_registry_entries(prefix)
available_installs = self.core.search_overlay_installs(prefix)
igame = self.core.lgd.get_overlay_install_info() igame = self.core.lgd.get_overlay_install_info()
if not igame: if not igame:
logger.info('No Legendary-managed installation found.') logger.info('No Legendary-managed installation found.')
@ -2131,6 +2122,11 @@ class LegendaryCLI:
logger.info(f'Installed version: {igame.version}') logger.info(f'Installed version: {igame.version}')
logger.info(f'Installed path: {igame.install_path}') logger.info(f'Installed path: {igame.install_path}')
if os.name != 'nt' and not prefix:
return
reg_paths = query_registry_entries(prefix)
available_installs = self.core.search_overlay_installs(prefix)
logger.info('Found available Overlay installations in:') logger.info('Found available Overlay installations in:')
for install in available_installs: for install in available_installs:
logger.info(f' - {install}') logger.info(f' - {install}')
@ -2202,6 +2198,11 @@ class LegendaryCLI:
print('Aborting...') print('Aborting...')
return return
if os.name != 'nt' and not prefix:
logger.info('Registry entries in prefixes (if any) have not been removed. '
f'This shoouldn\'t cause any issues as the overlay will simply fail to load.')
return
logger.info('Removing registry entries...') logger.info('Removing registry entries...')
remove_registry_entries(prefix) remove_registry_entries(prefix)
@ -2243,9 +2244,10 @@ class LegendaryCLI:
logger.error(f'The following exception occurred while waiting for the downloader to finish: {e!r}. ' logger.error(f'The following exception occurred while waiting for the downloader to finish: {e!r}. '
f'Try restarting the process, if it continues to fail please open an issue on GitHub.') f'Try restarting the process, if it continues to fail please open an issue on GitHub.')
else: else:
logger.info('Finished downloading, setting up overlay...')
self.core.finish_overlay_install(igame) self.core.finish_overlay_install(igame)
if os.name == 'nt' or prefix:
logger.info('Finished downloading, setting up overlay...')
# Check for existing registry entries, and remove them if necessary # Check for existing registry entries, and remove them if necessary
install_path = os.path.normpath(igame.install_path) install_path = os.path.normpath(igame.install_path)
reg_paths = query_registry_entries(prefix) reg_paths = query_registry_entries(prefix)
@ -2258,6 +2260,9 @@ class LegendaryCLI:
return return
add_registry_entries(install_path, prefix) add_registry_entries(install_path, prefix)
logger.info('Done.') logger.info('Done.')
else:
logger.info('Overlay has been downloaded. Run "legendary eos-overlay enable -h" to see '
'available options for enabling the overlay by specifying a prefix, app, or bottle.')
def crossover_setup(self, args): def crossover_setup(self, args):
if sys_platform != 'darwin': if sys_platform != 'darwin':