CLI mostly set up

This commit is contained in:
2026-02-02 17:33:54 +01:00
parent f07d2dacfb
commit 6ebae74f93
13 changed files with 126 additions and 22 deletions

View File

@@ -1,25 +1,38 @@
import argparse
import cli.args as cliargs
ap = argparse.ArgumentParser(
"archmgr",
description="A nixos-like declarative config and package manager for Arch Linux (or any other cdistro, with some tweaks)",
usage="archmgr [command] [options]",
)
ap.add_argument("--version", "-v", action="version", version="%(prog)s V0.0.1")
sp = ap.add_subparsers(
title="Commands",
metavar="Use 'archmgr [command] --help' to see help for each command",
dest="cmd"
import commands.commit as commit
import commands.config as config
import commands.init as init
import commands.pull as pull
import commands.push as push
args, ap = cliargs.add_cli_args()
if args.cmd == None:
ap.print_help()
print("\nSpecify a subcommand, '-h' or '-v'")
exit(64)
print(
"""
_
( )
_ _ _ __ ___| |__ ___ ___ __ _ __
/ _ ) __)/ ___) _ \\ _ _ \\/ _ \\ __)
( (_| | | ( (___| | | | ( ) ( ) | (_) | |
\\__ _)_) \\____)_) (_)_) (_) (_)\\__ |_)
( )_) |
\\___/
"""
)
# Apply subcommand
commit = sp.add_parser("commit", help="apply pending changes and commit to git repo")
commit.add_argument("--force", "-f", help="force apply", action="store_true")
commit.add_argument(
"--dry-run", "-d", help="print out files that would be changed", action="store_true"
)
push = sp.add_parser("push", help="push pending changes to git remote")
pull = sp.add_parser("pull", help="pull changes from git remote")
init = sp.add_parser("init", help="initialize a new archmgr repository")
print(ap.parse_args())
if args.cmd == "commit":
commit.commit(args.dry_run, args.force, args.no_apply, args.no_commit)
elif args.cmd == "config":
config.config()
elif args.cmd == "init":
init.init(args.force)
elif args.cmd == "pull":
pull.pull(args.rebase, args.apply)
elif args.cmd == "push":
push.push(args.force)