diff --git a/legendary/cli.py b/legendary/cli.py index 5704d5e..c1bb7a5 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -532,7 +532,7 @@ class LegendaryCLI: logger.error('Login failed! Cannot continue with download process.') exit(1) - if args.file_prefix or args.file_exclude_prefix or args.install_tag: + if args.file_prefix or args.file_exclude_prefix: args.no_install = True if args.update_only: @@ -589,6 +589,18 @@ class LegendaryCLI: self.core.lgd.config.set(game.app_name, 'install_tags', ','.join(args.install_tag)) else: args.install_tag = config_tags.split(',') + elif args.install_tag and not game.is_dlc and not args.no_install: + config_tags = ','.join(args.install_tag) + logger.info(f'Saving install tags for "{game.app_name}" to config: {config_tags}') + self.core.lgd.config.set(game.app_name, 'install_tags', config_tags) + elif not game.is_dlc: + config_tags = self.core.lgd.config.get(game.app_name, 'install_tags', fallback=None) + if config_tags and args.reset_sdl: + logger.info('Clearing install tags from config.') + self.core.lgd.config.remove_option(game.app_name, 'install_tags') + elif config_tags: + logger.info(f'Using install tags from config: {config_tags}') + args.install_tag = config_tags.split(',') logger.info('Preparing download...') # todo use status queue to print progress from CLI diff --git a/legendary/utils/config.py b/legendary/utils/config.py index 4ef809e..6621141 100644 --- a/legendary/utils/config.py +++ b/legendary/utils/config.py @@ -23,6 +23,13 @@ class LGDConf(configparser.ConfigParser): self.modified = True super().set(*args, **kwargs) + def remove_option(self, section, option): + if self.read_only: + return False + + self.modified = True + return super().remove_option(section, option) + def __setitem__(self, key, value): if self.read_only: return