From 39ffff45c6630ce31cb816de54b4cdfed9e61ade Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 2 Nov 2024 15:11:21 -0400 Subject: [PATCH 1/3] refactor: reorder and document repo view, pr create --- frg/cli.py | 57 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/frg/cli.py b/frg/cli.py index 4d9ca30..cf3aa0e 100644 --- a/frg/cli.py +++ b/frg/cli.py @@ -15,34 +15,67 @@ class CliContext(pydantic.BaseModel): @click.group() @click.pass_context def cli(ctx): + """ + A command-line tool to interact with different kinds of code forges. + """ + config = get_configuration() git_context = get_git_context(domain_aliases=config.domain_aliases) ctx.obj = CliContext(git=git_context, config=config) -@cli.command() +@cli.group() @click.pass_obj def pr(ctx): - forgejo_browser.create_pull_request_via_web( - head=ctx.git.current_branch, - host=ctx.git.host, - repo=ctx.git.repo_name, - owner=ctx.git.repo_author, - ) + """Interacts with pull requests.""" + pass + + +@pr.command(name="create") +@click.option( + "-w", + "--web", + type=bool, + is_flag=True, + help="Opens the pull-request page in the default browser.", +) +@click.pass_obj +def create_pr(ctx, web: bool): + """Interacts with pull requests.""" + + if web: + forgejo_browser.create_pull_request_via_web( + head=ctx.git.current_branch, + host=ctx.git.host, + repo=ctx.git.repo_name, + owner=ctx.git.repo_author, + ) @cli.group() @click.pass_obj def repo(ctx): + """Interacts with repositories""" pass -@repo.command() +@repo.command(name="view") +@click.option( + "-w", + "--web", + type=bool, + is_flag=True, + help="Opens the repository page in the default browser.", +) @click.pass_obj -def view(ctx): - forgejo_browser.view_repository_via_web( - host=ctx.git.host, repo=ctx.git.repo_name, owner=ctx.git.repo_author - ) +def view_repo(ctx, web: bool): + """View the current repository.""" + if web: + forgejo_browser.view_repository_via_web( + host=ctx.git.host, repo=ctx.git.repo_name, owner=ctx.git.repo_author + ) + else: + raise NotImplementedError("--web is the only mode supported.") def main(): -- 2.45.2 From 77eb2a810a090940f915dd6ea86da2a9597763cd Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 2 Nov 2024 15:19:37 -0400 Subject: [PATCH 2/3] docs: add readme stub --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f5fb78a..d3f6af9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ # forge-tools -Like `gh` and `tea`, but aspiring to be compatible with multiple forge types to avoid using different tools for each. \ No newline at end of file +Like `gh` and `tea`, but aspiring to be compatible with multiple forge types to avoid using different tools for each. + +## Usage + +`frg --help` will give you an overview of what's available! + +## Development + +This uses `uv` to manage dependencies; [make sure it's installed before proceeding](https://github.com/astral-sh/uv). + +### Direction + +The primary intention of this is to make a more hackable version of `gh`-like tooling for my own purposes. This is not aiming feature parity or production-level quality. -- 2.45.2 From f890219bf2c5b0f85d6a45dc82a152bd581ae2f5 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 2 Nov 2024 15:24:37 -0400 Subject: [PATCH 3/3] docs: add basic project metadata --- pyproject.toml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1cb7682..8664c9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,12 @@ [project] -name = "frg" -version = "0.1.0" -description = "Add your description here" +name = "forge-tools" +version = "0.0.0" +description = "Homegrown CLI tooling for code forges." +authors = [ + {name="Marc Cataford", email="hello@karnov.club"} +] readme = "README.md" +license={ file = "LICENSE" } requires-python = ">=3.12" dependencies = [ "click>=8.1.7", @@ -11,6 +15,10 @@ dependencies = [ "pyyaml>=6.0.2", ] +[project.urls] +homepage = "https://forge.karnov.club/marc/forge-tools" +issues = "https://forge.karnov.club/marc/forge-tools/issues" + [project.scripts] frg = "frg.cli:main" -- 2.45.2