From f5386d0e9826a0590b853d0d4c6efc6f701e2a3a Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Wed, 15 Apr 2026 15:59:36 +0200 Subject: [PATCH] feat: Add setup function --- archmgr.py | 10 +++++----- cli/args.py | 2 ++ commands/prepare.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 commands/prepare.py diff --git a/archmgr.py b/archmgr.py index 43a821c..680fbfd 100644 --- a/archmgr.py +++ b/archmgr.py @@ -5,7 +5,7 @@ import commands.config as config import commands.init as init import commands.pull as pull import commands.push as push - +import commands.prepare as setup if __name__ == "__main__": args, ap = cliargs.add_cli_args() @@ -15,8 +15,7 @@ if __name__ == "__main__": print("\nSpecify a subcommand, '-h' or '-v'") exit(64) - print( - """ + print(""" _ ( ) _ _ _ __ ___| |__ ___ ___ __ _ __ @@ -25,8 +24,7 @@ if __name__ == "__main__": \\__ _)_) \\____)_) (_)_) (_) (_)\\__ |_) ( )_) | \\___/ - """ - ) + """) try: if args.cmd == "commit": @@ -35,6 +33,8 @@ if __name__ == "__main__": config.config() elif args.cmd == "init": init.init(args.force) + elif args.cmd == "setup": + setup.setup() elif args.cmd == "pull": pull.pull(args.rebase, args.apply) elif args.cmd == "push": diff --git a/cli/args.py b/cli/args.py index 2f4f314..d9b45e7 100644 --- a/cli/args.py +++ b/cli/args.py @@ -34,6 +34,8 @@ def add_cli_args(): sp.add_parser("config", help="prints information about your config") + sp.add_parser("setup", help="Do initial setup, like installing required tools") + init = sp.add_parser("init", help="initialize a new archmgr repository") init.add_argument( "--force", diff --git a/commands/prepare.py b/commands/prepare.py new file mode 100644 index 0000000..6ca83d8 --- /dev/null +++ b/commands/prepare.py @@ -0,0 +1,13 @@ +import subprocess + +from commands.util import pacman + + +def setup(): + print("==> Installing required packages") + if not pacman.install_package_list(["git"]): + print("Git installation failed") + return + subprocess.run(["git", "clone", "https://aur.archlinux.org/yay.git"], cwd="/tmp") + subprocess.run(["makepkg", "-si"], cwd="/tmp/yay") + print("==> Installation completed")