From de64f73c464647a177ac26b3d30e4b2eba68fb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sun, 6 Oct 2024 19:39:42 +0200 Subject: [PATCH] Add since command --- nixprstatus/__main__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nixprstatus/__main__.py b/nixprstatus/__main__.py index 0580fde..4ded06d 100644 --- a/nixprstatus/__main__.py +++ b/nixprstatus/__main__.py @@ -1,7 +1,9 @@ import typer +import json from typing import Annotated from rich.console import Console from nixprstatus.pr import pr_merge_status +from nixprstatus.pr import commits_since app = typer.Typer() @@ -38,6 +40,26 @@ def pr( console.print(output, highlight=False) +@app.command() +def since( + commit_sha: str, + target: str = "nixos-unstable", + waybar_format: Annotated[ + bool, typer.Option(help="Output in format expected by waybar") + ] = False, +): + """ + Return the count of commits that has happened between the two refs. + """ + count = commits_since(target, commit_sha) + + if waybar_format: + output = {"text": str(count), "tooltip": f"{target}: {count}"} + typer.echo(json.dumps(output)) + return + typer.echo(count) + + def main(): app()