Add since command #7
| @@ -1,7 +1,9 @@ | |||||||
| import typer | import typer | ||||||
|  | import json | ||||||
| from typing import Annotated | from typing import Annotated | ||||||
| from rich.console import Console | from rich.console import Console | ||||||
| from nixprstatus.pr import pr_merge_status | from nixprstatus.pr import pr_merge_status | ||||||
|  | from nixprstatus.pr import commits_since | ||||||
|  |  | ||||||
| app = typer.Typer() | app = typer.Typer() | ||||||
|  |  | ||||||
| @@ -38,6 +40,26 @@ def pr( | |||||||
|         console.print(output, highlight=False) |         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(): | def main(): | ||||||
|     app() |     app() | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user