From a32e116b2ae75489c3f090d2be6361650186be5c Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Mon, 4 Oct 2021 10:51:16 -0400 Subject: [PATCH] feat: add separator for --san-only feat: add option to prefix the separator in the output --- checkcert/checkcert.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/checkcert/checkcert.py b/checkcert/checkcert.py index 55e69a0..66d10e9 100644 --- a/checkcert/checkcert.py +++ b/checkcert/checkcert.py @@ -115,8 +115,12 @@ def get_host_list_tuple(hosts: list) -> List[Tuple[str, int]]: is_flag=True, help="Output only the SAN names to use in passing to certbot for example", ) +@click.option( + "--pre/--no-pre", default=False, help="prefix the --san-only with the separator" +) +@click.option("--sep", "-s", default=" ", help="Separator to use in --san-only output") @click.argument("hosts", nargs=-1) -def main(san, dump, color, filename, valid, san_only, hosts): +def main(san, dump, color, filename, valid, san_only, sep, pre, hosts): """Return information about certificates given including their validity""" # setup the list of tuples # handle a domain given with a : in it to specify the port @@ -134,8 +138,11 @@ def main(san, dump, color, filename, valid, san_only, hosts): print(get_x509_text(hostinfo.cert).decode()) else: if san_only: - san_names = " ".join(get_alt_names(hostinfo.cert)) - print(san_names) + output_string = "" + if pre: + output_string += f"{sep}".lstrip() + output_string += f"{sep}".join(get_alt_names(hostinfo.cert)) + print(output_string) break output_string += ( f"{hostinfo.hostname} "