From 917a15f4653e3a8d9c5a3231c50483092e5acc88 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Mon, 22 Aug 2022 12:40:18 +0200 Subject: [PATCH] Add --version flag (#11) --- CHANGELOG.md | 4 ++++ cert_host_scraper/cli.py | 5 +++++ poetry.lock | 14 +++++++++++++- pyproject.toml | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42655d6..c982915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.4.0 + +- Add `--version` flag + # 0.3.1 - Validate `--status-code` is an integer diff --git a/cert_host_scraper/cli.py b/cert_host_scraper/cli.py index 3d0b69a..792c2a1 100644 --- a/cert_host_scraper/cli.py +++ b/cert_host_scraper/cli.py @@ -1,11 +1,15 @@ import logging import sys +from pathlib import Path import click from requests import RequestException from rich.console import Console from rich.progress import track from rich.table import Table +from single_source import get_version + +__version__ = get_version(__name__, Path(__file__).parent.parent) from cert_host_scraper import Options, Result, fetch_urls, validate_url @@ -21,6 +25,7 @@ def validate_status_code( @click.group() @click.option("--debug", is_flag=True, help="Whether to enable debug level output") +@click.version_option(__version__, message="%(prog)s: %(version)s") def cli(debug: bool): log_level = logging.DEBUG if debug else logging.INFO logging.basicConfig(level=log_level) diff --git a/poetry.lock b/poetry.lock index a5b8e1e..dc93114 100644 --- a/poetry.lock +++ b/poetry.lock @@ -334,6 +334,14 @@ pygments = ">=2.6.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] +[[package]] +name = "single-source" +version = "0.3.0" +description = "Access to the project version in Python code for PEP 621-style projects" +category = "main" +optional = false +python-versions = ">=3.6,<4.0" + [[package]] name = "soupsieve" version = "2.3.2.post1" @@ -378,7 +386,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "64f5741e51a21da78c64afa216380d02a08598b98107661c36f37d5b9d851152" +content-hash = "66a33636d1ffafb9d5dc595e80fdc71fa7a990d07386160cfb0c66b73b8dc666" [metadata.files] aiodns = [ @@ -862,6 +870,10 @@ rich = [ {file = "rich-11.2.0-py3-none-any.whl", hash = "sha256:d5f49ad91fb343efcae45a2b2df04a9755e863e50413623ab8c9e74f05aee52b"}, {file = "rich-11.2.0.tar.gz", hash = "sha256:1a6266a5738115017bb64a66c59c717e7aa047b3ae49a011ede4abdeffc6536e"}, ] +single-source = [ + {file = "single-source-0.3.0.tar.gz", hash = "sha256:b12705af958ca99d56ea9ce40bd9cc749378f4fe7ad03b1f9067e29daceef27d"}, + {file = "single_source-0.3.0-py3-none-any.whl", hash = "sha256:7bc87168ced50f638b6ab0cda4cc1ce9e80ee0e1220014397050d336d021a597"}, +] soupsieve = [ {file = "soupsieve-2.3.2.post1-py3-none-any.whl", hash = "sha256:3b2503d3c7084a42b1ebd08116e5f81aadfaea95863628c80a3b774a11b7c759"}, {file = "soupsieve-2.3.2.post1.tar.gz", hash = "sha256:fc53893b3da2c33de295667a0e19f078c14bf86544af307354de5fcf12a3f30d"}, diff --git a/pyproject.toml b/pyproject.toml index bf5d814..3144cd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ beautifulsoup4 = "^4.10.0" click = "^8.0.3" aiohttp = {extras = ["speedups"], version = "^3.8.1"} rich = "^11.0.0" +single-source = "^0.3.0" [tool.poetry.dev-dependencies] pytest = "^7.1.2"