feat: Diff packages

This commit is contained in:
2026-04-16 16:02:15 +02:00
parent bb123c23a1
commit c264a5bea2
3 changed files with 44 additions and 69 deletions
+11 -4
View File
@@ -1,6 +1,8 @@
import subprocess as sp
from typing import List
from commands.util.input_mgr import password
pkg_manager = ["yay", "--noconfirm"]
@@ -19,7 +21,13 @@ def remove_orphans() -> bool:
Returns:
True if successful, False otherwise
"""
return sp.run("pacman -Qdtq | sudo pacman -Rns --noconfirm -", capture_output=True).returncode == 0
return (
sp.run(
["pacman", "-Qdtq", "|", "sudo", "pacman", "-Rns", "--noconfirm", "-"],
capture_output=True,
).returncode
== 0
)
def uninstall_package_list(pkgs: List[str]) -> bool:
@@ -31,7 +39,7 @@ def uninstall_package_list(pkgs: List[str]) -> bool:
Returns:
True if successful, False otherwise
"""
# TODO: Add guard to protect against uninstalling archmgr
# TODO: Add guard to protect against uninstalling archmgr and confirm uninstalling crucial pkgs
# pkgs.index("archmgr")
# TODO: Consider if we want to print out stdout and stderr on err
return run_pkg_manager_cmd(["-Rs", *pkgs], True).returncode == 0
@@ -49,9 +57,8 @@ def install_package_list(pkgs: List[str]) -> bool:
def run_pkg_manager_cmd(
args: List[str], use_sudo: bool = False
) -> sp.CompletedProcess[str]:
# TODO: Get password
pw = ""
if use_sudo:
pw = password()
return sp.run([*pkg_manager, *args], capture_output=True, text=True, input=pw)
else:
return sp.run([*pkg_manager, *args], capture_output=True, text=True)