commit 713358505e46554f784cb494b5205c7e7bb78cbe Author: Waylon S. Walker Date: Fri Aug 29 20:24:14 2025 -0500 Initial Commit for scripts A dumping ground for dumb scripts. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..a46ee6f --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# scripts + +A dumping ground for dumb scripts. diff --git a/newrepo b/newrepo new file mode 100755 index 0000000..93bd829 --- /dev/null +++ b/newrepo @@ -0,0 +1,106 @@ +#!/usr/bin/env -S uv run --quiet --script +# /// script +# requires-python = ">=3.12" +# dependencies = ["typer",'httpx'] +# /// + +import subprocess +import httpx +import typer +from pathlib import Path + +app = typer.Typer() + +DEFAULT_REPO = Path.cwd().name + + +@app.command() +def create( + name: str = typer.Option(DEFAULT_REPO, help="Name of the repo", prompt=True), + description: str = typer.Option( + ..., "--description", "-d", help="Description for the repo", prompt=True + ), + remote: str = typer.Option("https://git.wayl.one", help="Base remote URL"), + org: str = typer.Option("waylon", help="Organization or username"), + branch: str = typer.Option("main", help="Branch to push"), + dry_run: bool = typer.Option(False, help="Dry run"), +): + typer.echo(f"Creating repo {name} on Forgejo...") + + cmd = ["tea", "repo", "create", "--name", name, "--description", description] + if dry_run: + typer.echo(" ".join(cmd)) + + else: + subprocess.run( + cmd, + check=True, + ) + + remote_url = f"{remote}/{org}/{name}.git" + typer.echo(f"Adding remote: {remote_url}") + if not Path(".gitignore").exists(): + cmd = [ + "curl", + "-L", + "https://www.gitignore.io/api/vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode", + ">", + ".gitignore", + ] + typer.echo("Creating .gitignore") + if dry_run: + typer.echo(" ".join(cmd)) + else: + gitignore = httpx.get("https://www.gitignore.io/api/vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode") + Path(".gitignore").write_text(gitignore.text) + + if not Path("README.md").exists(): + readme = f"""# {name} + +{description} +""" + typer.echo("Creating README.md") + if dry_run: + typer.echo(readme) + else: + Path("README.md").write_text(readme) + + if not Path(".git").exists(): + cmd = ["git", "init"] + if dry_run: + typer.echo(" ".join(cmd)) + else: + subprocess.run(cmd, check=True) + cmd = ["git", "add", "."] + if dry_run: + typer.echo(" ".join(cmd)) + else: + subprocess.run(cmd, check=True) + typer.echo("Added files") + cmd = ["git", "commit", "-m", f"Initial Commit for {name}\n\n{description}"] + if dry_run: + typer.echo(" ".join(cmd)) + else: + subprocess.run(cmd, check=True) + typer.echo("Created .git") + + cmd = ["git", "remote", "add", "origin", remote_url] + typer.echo("Adding remote") + if dry_run: + typer.echo(" ".join(cmd)) + else: + subprocess.run(cmd, check=True) + + typer.echo(f"Pushing branch {branch} to origin...") + cmd = ["git", "push", "-u", "origin", branch] + if dry_run: + cmd = ["git", "push", "-u", "origin", branch] + typer.echo(" ".join(cmd)) + else: + subprocess.run(cmd, check=True) + + typer.echo("✅ Done!") + + +if __name__ == "__main__": + app()