Skip to content

Commit

Permalink
Added "show dependencies" command
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Oct 17, 2020
1 parent 302b46c commit 23f8f20
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
23 changes: 16 additions & 7 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def add_dependency(self, dependency):
if dependency:
self.dependencies = self.dependencies + dependency

def parse_dependency(self):
def parse_dependency(self, output=False):
self.dependencies = list(set(self.dependencies))
for ignore in self.ignore:
if ignore in self.dependencies:
Expand All @@ -681,10 +681,19 @@ def parse_dependency(self):
slug = self.core.parse_cf_id(d, reverse=True)
if slug:
slugs.append(f'https://www.curseforge.com/wow/addons/{slug}')
for s in slugs:
if not self.core.check_if_installed(s):
processed.append(s)
if len(processed) > 0:
return ','.join(processed)
if output:
for s in slugs:
installed = self.core.check_if_installed(s)
if installed:
processed.append(installed['Name'])
else:
processed.append(f'cf:{s}')
return sorted(processed)
else:
return None
for s in slugs:
if not self.core.check_if_installed(s):
processed.append(s)
if len(processed) > 0:
return ','.join(processed)
else:
return None
20 changes: 18 additions & 2 deletions CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def setup_completer(self):
'wago': None},
'set': {'wago_api': None,
'wago_wow_account': WordCompleter(accounts, ignore_case=True, sentence=True)},
'show': {'dependencies': None},
'uri_integration': None,
'help': None,
'exit': None
Expand Down Expand Up @@ -658,6 +659,20 @@ def c_set(self, args):
else:
self.console.print('Unknown option.')

def c_show(self, args):
args = args.strip()
if args.startswith('dependencies'):
addons = sorted(list(filter(lambda k: k['URL'].startswith('https://www.curseforge.com/wow/addons/'),
self.core.config['Addons'])), key=lambda k: k['Name'].lower())
self.core.bulk_check(addons)
for addon in addons:
dependencies = DependenciesParser(self.core)
name, _, _, _, _, _, _, _, _, deps, _ = self.core.update_addon(addon['URL'], False, False)
dependencies.add_dependency(deps)
deps = dependencies.parse_dependency(output=True)
if len(deps) > 0:
self.console.print(f'[green]{name}[/green]\n{", ".join(deps)}')

def c_wago_update(self, _, verbose=True):
if os.path.isdir(Path('Interface/AddOns/WeakAuras')) or os.path.isdir(Path('Interface/AddOns/Plater')):
accounts = self.core.detect_accounts()
Expand Down Expand Up @@ -812,8 +827,9 @@ def c_help(self, _):
' [link=https://wago.io/account]https://wago.io/account[/link]\n'
'[green]set wago_wow_account [Account name][/green]\n\tSets WoW account used by Wago updater'
'.\n\tNeeded only if compatibile addons are used on more than one WoW account.\n'
'[green]uri_integration[/green]\n\tEnables integration with CurseForge page.\n\t[i]"Install"'
'[/i] button will now start this application.\n'
'[green]show dependencies[/green]\n\tDisplay a list of dependencies of all installed addons.'
'\n[green]uri_integration[/green]\n\tEnables integration with CurseForge page.\n\t[i]"Instal'
'l"[/i] button will now start this application.\n'
'\n[bold green]Supported URL:[/bold green]\n\thttps://www.curseforge.com/wow/addons/\[addon_'
'name] [bold white]|[/bold white] cf:\[addon_name]\n\thttps://www.wowinterface.com/downloads'
'/\[addon_name] [bold white]|[/bold white] wowi:\[addon_id]\n\thttps://www.tukui.org/addons.'
Expand Down

0 comments on commit 23f8f20

Please sign in to comment.