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)

70
cli/args.py Normal file
View File

@@ -0,0 +1,70 @@
import argparse
import argcomplete
def add_cli_args():
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",
)
# ┌ ┐
# │ Subcommands │
# └ ┘
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(
"--no-apply", "-n", help="do not apply to local system", action="store_true"
)
commit.add_argument(
"--no-commit", "-N", help="do not commit changes to repo", action="store_true"
)
commit.add_argument(
"--no-render", "-r", help="do not re-render renderables", action="store_true"
)
commit.add_argument(
"--dry-run",
"-d",
help="print out files that would be changed",
action="store_true",
)
sp.add_parser("config", help="prints information about your config")
init = sp.add_parser("init", help="initialize a new archmgr repository")
init.add_argument(
"--force",
"-f",
help="resets the git repository and initializes new archmgr repo",
action="store_true",
)
push = sp.add_parser("push", help="push pending changes to git remote")
push.add_argument(
"--force",
"-f",
help="force push (overriding possible remote changes)",
action="store_true",
)
pull = sp.add_parser("pull", help="pull changes from git remote")
pull.add_argument("--rebase", "-r", help="execute rebase", action="store_true")
pull.add_argument(
"--apply",
"-a",
help="also apply the changes to the local system",
action="store_true",
)
argcomplete.autocomplete(ap)
return ap.parse_args(), ap

7
commands/commit.py Normal file
View File

@@ -0,0 +1,7 @@
def commit(
dry_run: bool = False,
force: bool = False,
no_apply: bool = False,
no_commit: bool = False,
):
print("Commit, force:", force)

6
commands/config.py Normal file
View File

@@ -0,0 +1,6 @@
def config():
print(
"""
Your config can be found at
"""
)

2
commands/init.py Normal file
View File

@@ -0,0 +1,2 @@
def init(force: bool = False):
print("Init")

2
commands/pull.py Normal file
View File

@@ -0,0 +1,2 @@
def pull(rebase: bool = False, apply: bool = False):
print("pull")

2
commands/push.py Normal file
View File

@@ -0,0 +1,2 @@
def push(force: bool = False):
print("push")

View File

View File

View File

View File

View File

@@ -1 +1,3 @@
pylette
argcomplete
inquirer