From 760520553ab343842b8b2d07fbc906739347eb29 Mon Sep 17 00:00:00 2001 From: Muhammad Usaid Rehman Date: Wed, 16 Oct 2024 21:39:29 +0500 Subject: [PATCH] --version option added --- network_latency_monitor/cli.py | 13 +++++++++++++ network_latency_monitor/main.py | 10 +--------- pyproject.toml | 3 +-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/network_latency_monitor/cli.py b/network_latency_monitor/cli.py index 333cd2c..7d47bba 100644 --- a/network_latency_monitor/cli.py +++ b/network_latency_monitor/cli.py @@ -12,6 +12,7 @@ """ import argparse +from importlib.metadata import version, PackageNotFoundError def parse_arguments() -> argparse.Namespace: @@ -94,6 +95,18 @@ def parse_arguments() -> argparse.Namespace: help="Regenerate the default config.yaml file.", ) + try: + package_version = version("network-latency-monitor") + except PackageNotFoundError: + package_version = "unknown" + + optional.add_argument( + "--version", + action="version", + version=f"NLM version {package_version}", + help="Show the application's version and exit.", + ) + # Aggregation arguments aggregation = parser.add_argument_group("Aggregation Options") diff --git a/network_latency_monitor/main.py b/network_latency_monitor/main.py index 88c25c6..fd6efa0 100644 --- a/network_latency_monitor/main.py +++ b/network_latency_monitor/main.py @@ -37,14 +37,7 @@ from network_latency_monitor.console_manager import NullConsole, console_proxy from network_latency_monitor.config import DEFAULT_CONFIG -# TODO: (16/10/24) - implement verbosity levels (done) -# - refactor log statements in all files to use loguru (done) -# - refactor plot_generator.py to suppress console output for -q (done) -# - test verbosity option in config file (done) -# - update documentation for verbosity flags (done) -# - incorporate use of --yes flag -# - fix console.print statements in config.py -# - bypass warnings and confirmations +# TODO: (16/10/24) - incorporate --version flag async def main(): @@ -220,4 +213,3 @@ def cli(): if __name__ == "__main__": cli() - diff --git a/pyproject.toml b/pyproject.toml index 9bd312c..b658dad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "network-latency-monitor" -version = "0.2.1" +version = "0.2.2" description = "Monitor your network latency using real-time plots and cumulative plots" authors = ["Muhammad Usaid Rehman "] homepage = "https://github.com/m-usaid99/Network-Latency-Monitor" @@ -43,4 +43,3 @@ build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] nlm = "network_latency_monitor.main:cli" -