From bac1bd7bd69b59e87e382f8ec6a0b9b610434ddd Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 1 Oct 2024 17:12:55 +0100 Subject: [PATCH] Add shortcut for getting the number of items --- README.md | 1 + heroku_audit/format.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 0416ee5..88e1eb5 100644 --- a/README.md +++ b/README.md @@ -62,5 +62,6 @@ By default, a pretty table is output, for easy consumption by humans. `--format` - `table` (Default) - `csv` - `json` +- `count` Progress output is automatically removed when running non-interactively. diff --git a/heroku_audit/format.py b/heroku_audit/format.py index 3710fbb..47d8ff3 100644 --- a/heroku_audit/format.py +++ b/heroku_audit/format.py @@ -26,12 +26,17 @@ class Format(str, Enum): TABLE = "table" CSV = "csv" JSON = "json" + COUNT = "count" FormatOption = Annotated[Format, typer.Option("--format")] def display_data(data: list[dict], display_format: Format) -> None: + if display_format == Format.COUNT: + print(len(data)) + return + if not data: return