Skip to content

Commit

Permalink
Update dank.winget.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SirDank committed Oct 9, 2024
1 parent f002fb7 commit 136976a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions __modules__/dank.winget.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,39 @@ def main():
if cmd.lower().startswith('search '):
cmd = subprocess.run(['winget', 'search', '--accept-source-agreements', cmd[7:]], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
if cmd.returncode == 0:
handle_response(cmd, results, 'search')
if len(cmd) > 0:
handle_response(cmd, results, 'search')
else:
print(clr("\n [KNOWN ERROR]: Please report this issue on GitHub / Discord Support Ticket to help fix it!",2))
else:
print(clr(f"\n [ERROR]: {cmd.stdout.decode('utf-8')}",2))

elif cmd.lower().startswith('installed'):
cmd = subprocess.run(['winget', 'list', '--accept-source-agreements'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
if cmd.returncode == 0:
handle_response(cmd, results, 'installed')
if len(cmd) > 0:
handle_response(cmd, results, 'installed')
else:
print(clr("\n [KNOWN ERROR]: Please report this issue on GitHub / Discord Support Ticket to help fix it!",2))
else:
print(clr(f"\n [ERROR]: {cmd.stdout.decode('utf-8')}",2))

elif cmd.lower().startswith('updates') or cmd.lower().startswith('update-all'):
choice = cmd.lower()
cmd = subprocess.run(['winget', 'upgrade', '--accept-source-agreements'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
if cmd.returncode == 0:
if not choice.startswith('update-all'):
handle_response(cmd, results, 'updates')
if len(cmd) > 0:
if not choice.startswith('update-all'):
handle_response(cmd, results, 'updates')
else:
handle_response(cmd, results, 'update-all')
max = len(results) - 1
for index in range(1, max + 1):
print(clr(f"\n - [{index}/{max}] Updating {results[index]['name']}...\n"))
os.system(f"winget upgrade --interactive --id {results[index]['id']}")
print()
else:
handle_response(cmd, results, 'update-all')
max = len(results) - 1
for index in range(1, max + 1):
print(clr(f"\n - [{index}/{max}] Updating {results[index]['name']}...\n"))
os.system(f"winget upgrade --interactive --id {results[index]['id']}")
print()
print(clr("\n [KNOWN ERROR]: Please report this issue on GitHub / Discord Support Ticket to help fix it!",2))
else:
print(clr(f"\n [ERROR]: {cmd.stdout.decode('utf-8')}",2))

Expand Down

0 comments on commit 136976a

Please sign in to comment.