summaryrefslogtreecommitdiff
path: root/src/caelestia/utils/version.py
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-07-04 20:45:53 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-07-04 20:45:53 +1000
commit9b01d62dc169e49c168864285963829ca39d3ab7 (patch)
treef3baf1dbb54e26d1788f95e6b1b5161b4e2dba1c /src/caelestia/utils/version.py
parentdiscord: add borders (diff)
downloadcaelestia-cli-9b01d62dc169e49c168864285963829ca39d3ab7.tar.gz
caelestia-cli-9b01d62dc169e49c168864285963829ca39d3ab7.tar.bz2
caelestia-cli-9b01d62dc169e49c168864285963829ca39d3ab7.zip
feat: add version flag
Diffstat (limited to 'src/caelestia/utils/version.py')
-rw-r--r--src/caelestia/utils/version.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/caelestia/utils/version.py b/src/caelestia/utils/version.py
new file mode 100644
index 0000000..8f9ccba
--- /dev/null
+++ b/src/caelestia/utils/version.py
@@ -0,0 +1,54 @@
+import subprocess
+
+from caelestia.utils.paths import config_dir
+
+
+def print_version() -> None:
+ print("Packages:")
+ pkgs = ["caelestia-shell-git", "caelestia-cli-git", "caelestia-meta"]
+ versions = subprocess.run(["pacman", "-Q", *pkgs], stdout=subprocess.PIPE, text=True).stdout
+
+ for pkg in pkgs:
+ if pkg not in versions:
+ print(f" {pkg} not installed")
+ print("\n".join(f" {pkg}" for pkg in versions.splitlines()))
+
+ caelestia_dir = (config_dir / "hypr").resolve().parent
+ print("\nCaelestia:")
+ caelestia_ver = subprocess.check_output(
+ ["git", "--git-dir", caelestia_dir / ".git", "rev-list", "--format=%B", "--max-count=1", "HEAD"], text=True
+ )
+ print(" Last commit:", caelestia_ver.split()[1])
+ print(" Commit message:", *caelestia_ver.splitlines()[1:])
+
+ print("\nQuickshell:")
+ print(" ", subprocess.check_output(["qs", "--version"], text=True).strip())
+
+ local_shell_dir = config_dir / "quickshell/caelestia"
+ if local_shell_dir.exists():
+ print("\nLocal copy of shell found:")
+
+ try:
+ shell_ver = subprocess.check_output(
+ [
+ "git",
+ "--git-dir",
+ local_shell_dir / ".git",
+ "rev-list",
+ "--format=%B",
+ "--max-count=1",
+ "upstream/main",
+ ],
+ text=True,
+ )
+ print(" Last merged upstream commit:", shell_ver.split()[1])
+ print(" Commit message:", *shell_ver.splitlines()[1:])
+ except subprocess.CalledProcessError:
+ print(" Unable to determine last merged upstream commit.")
+
+ shell_ver = subprocess.check_output(
+ ["git", "--git-dir", local_shell_dir / ".git", "rev-list", "--format=%B", "--max-count=1", "HEAD"],
+ text=True,
+ )
+ print("\n Last commit:", shell_ver.split()[1])
+ print(" Commit message:", *shell_ver.splitlines()[1:])