diff --git a/Documents/bin/git-manage b/Documents/bin/git-manage new file mode 100755 index 0000000000000000000000000000000000000000..37e092a61dad40577c4a5c8d5240c88cf0589601 --- /dev/null +++ b/Documents/bin/git-manage @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +# pylint: disable=invalid-name +"""Manage my Git infrastructure.""" + +import argparse +import os +import os.path +import sys + +sys.path.append(os.path.expanduser("~/Documents/bin")) + +# import rcfiles.git # noqa: E402 pylint: disable=wrong-import-position +# import rcfiles.github # noqa: E402 pylint: disable=wrong-import-position +# import rcfiles.gitlab # noqa: E402 pylint: disable=wrong-import-position + + +def create_repo(args): + """Create a new repository.""" + print(args) + + +def mirror_repo(args): + """Mirror a GitLab repository to GitHub.""" + print(args) + + +def archive_repo(args): + """Archive a repository.""" + print(args) + + +def main(): + """The main function.""" + parser = argparse.ArgumentParser(description=__doc__) + subparsers = parser.add_subparsers( + title="Commands", required=True, dest="command" + ) + + parser_create = subparsers.add_parser( + "new", help="Create a new repository." + ) + parser_create.set_defaults(func=create_repo) + parser_create.add_argument( + "name", help="Name of the repository.", nargs="?" + ) + parser_create.add_argument( + "-m", "--mirror", help="Setup a mirror in GitHub.", action="store_true" + ) + parser_create.add_argument( + "--github", + help="Create the repository in GitHub.", + action="store_true", + ) + + parser_mirror = subparsers.add_parser( + "mirror", help="Mirror a GitLab repository to GitHub." + ) + parser_mirror.set_defaults(func=mirror_repo) + parser_mirror.add_argument( + "name", help="Name of the GitLab repository.", nargs="?" + ) + + parser_archive = subparsers.add_parser( + "archive", help="Archive a repository." + ) + parser_archive.set_defaults(func=archive_repo) + parser_archive.add_argument( + "name", help="Name of the repository.", nargs="?" + ) + parser_archive.add_argument( + "--github", help="The repository is in GitHub.", action="store_true" + ) + + args = parser.parse_args() + args.func(args) + + +if __name__ == "__main__": + main()