forked from Shinonome/caelestia-cli
feat: add version flag
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
from caelestia.parser import parse_args
|
||||
from caelestia.utils.version import print_version
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser, args = parse_args()
|
||||
if "cls" in args:
|
||||
if args.version:
|
||||
print_version()
|
||||
elif "cls" in args:
|
||||
args.cls(args).run()
|
||||
else:
|
||||
parser.print_help()
|
||||
|
||||
@@ -8,6 +8,7 @@ from caelestia.utils.wallpaper import get_wallpaper
|
||||
|
||||
def parse_args() -> (argparse.ArgumentParser, argparse.Namespace):
|
||||
parser = argparse.ArgumentParser(prog="caelestia", description="Main control script for the Caelestia dotfiles")
|
||||
parser.add_argument("-v", "--version", action="store_true", help="print the current version")
|
||||
|
||||
# Add subcommand parsers
|
||||
command_parser = parser.add_subparsers(
|
||||
|
||||
@@ -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:])
|
||||
Reference in New Issue
Block a user