From 6521d377dba346295ffe9ee3080263ce00bcc0d0 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Mon, 25 Sep 2023 23:45:02 +0200 Subject: [PATCH] Add colours to CLI output (#86) * Add colours to CLI output * Fix lint --- cert_host_scraper/cli.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cert_host_scraper/cli.py b/cert_host_scraper/cli.py index d13831d..1b6e5eb 100644 --- a/cert_host_scraper/cli.py +++ b/cert_host_scraper/cli.py @@ -4,6 +4,7 @@ import click from requests import RequestException +from rich import box from rich.console import Console from rich.progress import track from rich.table import Table @@ -87,14 +88,20 @@ def search(search: str, status_code: int, timeout: int, clean: bool, strip: bool else: display = result.scraped - table = Table(show_header=True, header_style="bold") + table = Table(show_header=True, header_style="bold", box=box.MINIMAL) table.add_column("URL") table.add_column("Status Code") for url_result in display: display_code = str(url_result.status_code) if url_result.status_code == -1: display_code = "-" - table.add_row(url_result.url, display_code) + + url = url_result.url + if url_result.status_code == 200: + display_code = f"[green]{display_code}[/green]" + url = f"[green]{url}[/green]" + + table.add_row(url, display_code) console = Console() console.print(table)