Skip to content

Commit

Permalink
Add colours to CLI output
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse committed Sep 25, 2023
1 parent b058685 commit 2b9a32e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cert_host_scraper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from rich.console import Console
from rich.progress import track
from rich.table import Table
from rich import box

from cert_host_scraper import __version__
from cert_host_scraper.scraper import Options, Result, fetch_urls, validate_url
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2b9a32e

Please sign in to comment.