Skip to content

Commit

Permalink
Merge pull request #109 from NTFSvolume/additive_cli_args
Browse files Browse the repository at this point in the history
Enhancement: skip_hosts/only_hosts cli values append to config values
  • Loading branch information
jbsparrow authored Sep 22, 2024
2 parents 77684b0 + bf1c2c5 commit 338ae98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/managers/args_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def __init__(self):
self.retry_any = False
self.retry_maintenance = False
self.webhook_url = ""

self.max_items = None

self.immediate_download = False
self.no_ui = False
self.load_config_from_args = False
self.load_config_name = ""
self.other_links: list = []
self.additive_args = ["skip_hosts","only_hosts"]

# Files
self.input_file = None
Expand Down
21 changes: 9 additions & 12 deletions cyberdrop_dl/managers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,16 @@ async def async_db_hash_startup(self):

async def args_consolidation(self) -> None:
"""Consolidates runtime arguments with config values"""
cli_settings_groups = ["Download_Options","File_Size_Limits","Ignore_Options","Runtime_Options"]
for arg in self.args_manager.parsed_args:
if arg in config_definitions.settings['Download_Options']:
if self.args_manager.parsed_args[arg] != config_definitions.settings['Download_Options'][arg]:
self.config_manager.settings_data['Download_Options'][arg] = self.args_manager.parsed_args[arg]
elif arg in config_definitions.settings['File_Size_Limits']:
if self.args_manager.parsed_args[arg] != config_definitions.settings['File_Size_Limits'][arg]:
self.config_manager.settings_data['File_Size_Limits'][arg] = self.args_manager.parsed_args[arg]
elif arg in config_definitions.settings['Ignore_Options']:
if self.args_manager.parsed_args[arg] != config_definitions.settings['Ignore_Options'][arg]:
self.config_manager.settings_data['Ignore_Options'][arg] = self.args_manager.parsed_args[arg]
elif arg in config_definitions.settings['Runtime_Options']:
if self.args_manager.parsed_args[arg] != config_definitions.settings['Runtime_Options'][arg]:
self.config_manager.settings_data['Runtime_Options'][arg] = self.args_manager.parsed_args[arg]
for cli_settings_group in cli_settings_groups:
if arg in config_definitions.settings[cli_settings_group]:
if self.args_manager.parsed_args[arg] == config_definitions.settings[cli_settings_group][arg]:
continue
if arg in self.args_manager.additive_args:
self.config_manager.settings_data[cli_settings_group][arg] += self.args_manager.parsed_args[arg]
else:
self.config_manager.settings_data[cli_settings_group][arg] = self.args_manager.parsed_args[arg]

async def args_logging(self) -> None:
"""Logs the runtime arguments"""
Expand Down

0 comments on commit 338ae98

Please sign in to comment.