53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Push RegSpy program to Modaic Hub.
|
|
|
|
Usage:
|
|
uv run push.py your-username/regspy
|
|
uv run push.py your-username/regspy --with-code --commit-message "Initial"
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
|
|
from regspy import RegexConfig, RegexProgram
|
|
|
|
|
|
def create_parser() -> argparse.ArgumentParser:
|
|
parser = argparse.ArgumentParser(
|
|
description="Push RegSpy PrecompiledProgram to Modaic Hub",
|
|
)
|
|
parser.add_argument("repo", help="Hub repo in the form username/name")
|
|
parser.add_argument("--with-code", action="store_true", help="Bundle code with the push")
|
|
parser.add_argument("--commit-message", help="Optional commit message")
|
|
parser.add_argument("--branch", help="Optional branch name")
|
|
parser.add_argument("--tag", help="Optional tag name")
|
|
parser.add_argument("--private", action="store_true", help="Push to a private repo")
|
|
return parser
|
|
|
|
|
|
def main() -> None:
|
|
parser = create_parser()
|
|
args = parser.parse_args()
|
|
|
|
program = RegexProgram(RegexConfig())
|
|
|
|
push_kwargs: dict[str, object] = {
|
|
"with_code": args.with_code,
|
|
"private": args.private,
|
|
}
|
|
if args.commit_message:
|
|
push_kwargs["commit_message"] = args.commit_message
|
|
if args.branch:
|
|
push_kwargs["branch"] = args.branch
|
|
if args.tag:
|
|
push_kwargs["tag"] = args.tag
|
|
|
|
program.push_to_hub(args.repo, **push_kwargs)
|
|
print(f"Pushed to {args.repo}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|