Skip to content

Commit

Permalink
Add colours to CLI output (#86)
Browse files Browse the repository at this point in the history
* Add colours to CLI output

* Fix lint
  • Loading branch information
inverse authored Sep 25, 2023
1 parent 246320b commit 6521d37
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 @@ -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
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 6521d37

Please sign in to comment.