CLI mostly set up
This commit is contained in:
57
archmgr.py
57
archmgr.py
@@ -1,25 +1,38 @@
|
|||||||
import argparse
|
import cli.args as cliargs
|
||||||
|
|
||||||
ap = argparse.ArgumentParser(
|
import commands.commit as commit
|
||||||
"archmgr",
|
import commands.config as config
|
||||||
description="A nixos-like declarative config and package manager for Arch Linux (or any other cdistro, with some tweaks)",
|
import commands.init as init
|
||||||
usage="archmgr [command] [options]",
|
import commands.pull as pull
|
||||||
)
|
import commands.push as push
|
||||||
ap.add_argument("--version", "-v", action="version", version="%(prog)s V0.0.1")
|
|
||||||
sp = ap.add_subparsers(
|
args, ap = cliargs.add_cli_args()
|
||||||
title="Commands",
|
|
||||||
metavar="Use 'archmgr [command] --help' to see help for each command",
|
if args.cmd == None:
|
||||||
dest="cmd"
|
ap.print_help()
|
||||||
|
print("\nSpecify a subcommand, '-h' or '-v'")
|
||||||
|
exit(64)
|
||||||
|
|
||||||
|
print(
|
||||||
|
"""
|
||||||
|
_
|
||||||
|
( )
|
||||||
|
_ _ _ __ ___| |__ ___ ___ __ _ __
|
||||||
|
/ _ ) __)/ ___) _ \\ _ _ \\/ _ \\ __)
|
||||||
|
( (_| | | ( (___| | | | ( ) ( ) | (_) | |
|
||||||
|
\\__ _)_) \\____)_) (_)_) (_) (_)\\__ |_)
|
||||||
|
( )_) |
|
||||||
|
\\___/
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Apply subcommand
|
if args.cmd == "commit":
|
||||||
commit = sp.add_parser("commit", help="apply pending changes and commit to git repo")
|
commit.commit(args.dry_run, args.force, args.no_apply, args.no_commit)
|
||||||
commit.add_argument("--force", "-f", help="force apply", action="store_true")
|
elif args.cmd == "config":
|
||||||
commit.add_argument(
|
config.config()
|
||||||
"--dry-run", "-d", help="print out files that would be changed", action="store_true"
|
elif args.cmd == "init":
|
||||||
)
|
init.init(args.force)
|
||||||
push = sp.add_parser("push", help="push pending changes to git remote")
|
elif args.cmd == "pull":
|
||||||
pull = sp.add_parser("pull", help="pull changes from git remote")
|
pull.pull(args.rebase, args.apply)
|
||||||
init = sp.add_parser("init", help="initialize a new archmgr repository")
|
elif args.cmd == "push":
|
||||||
|
push.push(args.force)
|
||||||
print(ap.parse_args())
|
|
||||||
|
|||||||
70
cli/args.py
Normal file
70
cli/args.py
Normal 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
7
commands/commit.py
Normal 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
6
commands/config.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
def config():
|
||||||
|
print(
|
||||||
|
"""
|
||||||
|
Your config can be found at
|
||||||
|
"""
|
||||||
|
)
|
||||||
2
commands/init.py
Normal file
2
commands/init.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
def init(force: bool = False):
|
||||||
|
print("Init")
|
||||||
2
commands/pull.py
Normal file
2
commands/pull.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
def pull(rebase: bool = False, apply: bool = False):
|
||||||
|
print("pull")
|
||||||
2
commands/push.py
Normal file
2
commands/push.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
def push(force: bool = False):
|
||||||
|
print("push")
|
||||||
@@ -1 +1,3 @@
|
|||||||
pylette
|
pylette
|
||||||
|
argcomplete
|
||||||
|
inquirer
|
||||||
|
|||||||
Reference in New Issue
Block a user