mirror of
https://codeberg.org/Mo8it/dotfiles.git
synced 2025-01-03 15:49:19 +00:00
49 lines
1.2 KiB
Text
49 lines
1.2 KiB
Text
#!/usr/bin/env xonsh
|
|
|
|
import re
|
|
|
|
def get_out(out_obj):
|
|
for line in out_obj:
|
|
print(line, end="")
|
|
|
|
return out_obj.out.split("\n")
|
|
|
|
def press_to_exit():
|
|
read -s -n 1 -p "Exit"
|
|
|
|
def main():
|
|
if $ARG1 == "rpm-ostree":
|
|
out = get_out(!(rpm-ostree upgrade | tee))
|
|
|
|
if out[-2] != "No upgrade available.":
|
|
press_to_exit()
|
|
elif $ARG1 == "flatpak":
|
|
flatpak update -y
|
|
flatpak remove --delete-data --unused
|
|
elif $ARG1 == "pipx":
|
|
out = get_out(!(pipx upgrade-all --include-injected | tee))
|
|
|
|
if "did not change" not in out[-2]:
|
|
press_to_exit()
|
|
elif $ARG1 == "cargo":
|
|
out = get_out(!(cargo install-update -a | tee))
|
|
|
|
pattern = r"updated (\d+) packages"
|
|
match = re.search(pattern, out[-2])
|
|
|
|
if match is None:
|
|
press_to_exit()
|
|
return
|
|
|
|
num_updated_packages = match.group(1)
|
|
|
|
if num_updated_packages != "0":
|
|
press_to_exit()
|
|
elif $ARG1 == "npm":
|
|
npm update -g
|
|
elif $ARG1 == "nvim":
|
|
nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerSync"
|
|
else:
|
|
print(f"{$ARG1} not found!")
|
|
|
|
main()
|