diff --git a/archmgr.py b/archmgr.py index 21179c4..6135ea1 100644 --- a/archmgr.py +++ b/archmgr.py @@ -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) diff --git a/cli/args.py b/cli/args.py new file mode 100644 index 0000000..9952bdb --- /dev/null +++ b/cli/args.py @@ -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 diff --git a/commands/commit.py b/commands/commit.py new file mode 100644 index 0000000..a518cb2 --- /dev/null +++ b/commands/commit.py @@ -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) diff --git a/commands/config.py b/commands/config.py new file mode 100644 index 0000000..fbab427 --- /dev/null +++ b/commands/config.py @@ -0,0 +1,6 @@ +def config(): + print( + """ + Your config can be found at + """ + ) diff --git a/commands/init.py b/commands/init.py new file mode 100644 index 0000000..5cc5cb4 --- /dev/null +++ b/commands/init.py @@ -0,0 +1,2 @@ +def init(force: bool = False): + print("Init") diff --git a/commands/pull.py b/commands/pull.py new file mode 100644 index 0000000..9ef9c79 --- /dev/null +++ b/commands/pull.py @@ -0,0 +1,2 @@ +def pull(rebase: bool = False, apply: bool = False): + print("pull") diff --git a/commands/push.py b/commands/push.py new file mode 100644 index 0000000..9e7622a --- /dev/null +++ b/commands/push.py @@ -0,0 +1,2 @@ +def push(force: bool = False): + print("push") diff --git a/config/diff.py b/commands/util/git.py similarity index 100% rename from config/diff.py rename to commands/util/git.py diff --git a/config/parse.py b/config/parse.py deleted file mode 100644 index e69de29..0000000 diff --git a/config/syntax.py b/config/syntax.py deleted file mode 100644 index e69de29..0000000 diff --git a/git/setup.py b/git/setup.py deleted file mode 100644 index e69de29..0000000 diff --git a/packages/init.py b/packages/init.py deleted file mode 100644 index e69de29..0000000 diff --git a/requirements.txt b/requirements.txt index 22ace8e..2457530 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ pylette +argcomplete +inquirer