From 92474fb71dbad123ba21a807c0d02048bc2d2159 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 14 Feb 2026 18:41:45 +0330 Subject: [PATCH 1/6] fix : CLI modified --- ipspot/cli.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/ipspot/cli.py b/ipspot/cli.py index 287417e..3fb5081 100644 --- a/ipspot/cli.py +++ b/ipspot/cli.py @@ -93,8 +93,8 @@ def _print_report(ipv4_api: IPv4API, print(" Error: {public_ipv6_result}".format(public_ipv6_result=PUBLIC_IPV6_ERROR)) -def main() -> None: # pragma: no cover - """CLI main function.""" +def _parse_args() -> argparse.Namespace: + """Parse arguments.""" parser = argparse.ArgumentParser() parser.add_argument( '--ipv4-api', @@ -117,8 +117,16 @@ def main() -> None: # pragma: no cover parser.add_argument('--max-retries', help='number of retries', type=int, default=0) parser.add_argument('--retry-delay', help='delay between retries (in seconds)', type=float, default=1.0) parser.add_argument('--backoff-factor', help='backoff factor', type=float, default=1.0) - args = parser.parse_args() + return args + + +def _run(args: argparse.Namespace) -> None: + """ + Run ipspot CLI. + + :param args: arguments + """ if args.version: print(IPSPOT_VERSION) elif args.info: @@ -135,3 +143,14 @@ def main() -> None: # pragma: no cover max_retries=args.max_retries, retry_delay=args.retry_delay, backoff_factor=args.backoff_factor) + + +def main() -> None: # pragma: no cover + """CLI main function.""" + try: + args = parse_args() + run(args) + except KeyboardInterrupt: + print("message") + + From 502667946f97e9f06de43a1a8cad55dcb37c8129 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 14 Feb 2026 18:44:19 +0330 Subject: [PATCH 2/6] feat : EXIT_MESSAGE added --- ipspot/cli.py | 5 +++-- ipspot/params.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ipspot/cli.py b/ipspot/cli.py index 3fb5081..c39c797 100644 --- a/ipspot/cli.py +++ b/ipspot/cli.py @@ -10,6 +10,7 @@ from .params import IPSPOT_OVERVIEW, IPSPOT_REPO, IPSPOT_VERSION from .params import PUBLIC_IPV4_ERROR, PRIVATE_IPV4_ERROR from .params import PUBLIC_IPV6_ERROR, PRIVATE_IPV6_ERROR +from .params import EXIT_MESSAGE def _print_ipspot_info() -> None: # pragma: no cover @@ -150,7 +151,7 @@ def main() -> None: # pragma: no cover try: args = parse_args() run(args) - except KeyboardInterrupt: - print("message") + except (KeyboardInterrupt, EOFError): + print(EXIT_MESSAGE) diff --git a/ipspot/params.py b/ipspot/params.py index cec53bb..60ba3d3 100644 --- a/ipspot/params.py +++ b/ipspot/params.py @@ -77,3 +77,5 @@ class IPv6API(Enum): PRIVATE_IPV4_ERROR = "Unable to retrieve private IPv4 address." PUBLIC_IPV6_ERROR = "Unable to retrieve public IPv6 information." PRIVATE_IPV6_ERROR = "Unable to retrieve private IPv6 address." + +EXIT_MESSAGE = "See you. Bye!" From e364fa4bcdd5a4086ce16033d51c6acf60b9abf3 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 14 Feb 2026 18:47:28 +0330 Subject: [PATCH 3/6] doc : pragma: no cover --- ipspot/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipspot/cli.py b/ipspot/cli.py index c39c797..b76914b 100644 --- a/ipspot/cli.py +++ b/ipspot/cli.py @@ -94,7 +94,7 @@ def _print_report(ipv4_api: IPv4API, print(" Error: {public_ipv6_result}".format(public_ipv6_result=PUBLIC_IPV6_ERROR)) -def _parse_args() -> argparse.Namespace: +def _parse_args() -> argparse.Namespace: # pragma: no cover """Parse arguments.""" parser = argparse.ArgumentParser() parser.add_argument( @@ -122,7 +122,7 @@ def _parse_args() -> argparse.Namespace: return args -def _run(args: argparse.Namespace) -> None: +def _run(args: argparse.Namespace) -> None: # pragma: no cover """ Run ipspot CLI. From 6bcf7f8897e0904082087ca03447c9d4eb98b9ae Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 14 Feb 2026 18:48:08 +0330 Subject: [PATCH 4/6] fix : autopep8 --- ipspot/cli.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ipspot/cli.py b/ipspot/cli.py index b76914b..7c2a504 100644 --- a/ipspot/cli.py +++ b/ipspot/cli.py @@ -94,7 +94,7 @@ def _print_report(ipv4_api: IPv4API, print(" Error: {public_ipv6_result}".format(public_ipv6_result=PUBLIC_IPV6_ERROR)) -def _parse_args() -> argparse.Namespace: # pragma: no cover +def _parse_args() -> argparse.Namespace: # pragma: no cover """Parse arguments.""" parser = argparse.ArgumentParser() parser.add_argument( @@ -122,7 +122,7 @@ def _parse_args() -> argparse.Namespace: # pragma: no cover return args -def _run(args: argparse.Namespace) -> None: # pragma: no cover +def _run(args: argparse.Namespace) -> None: # pragma: no cover """ Run ipspot CLI. @@ -153,5 +153,3 @@ def main() -> None: # pragma: no cover run(args) except (KeyboardInterrupt, EOFError): print(EXIT_MESSAGE) - - From e05e1cd28d74d1cba7fababf14e3d2e4e0f6c632 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 14 Feb 2026 18:49:00 +0330 Subject: [PATCH 5/6] doc : CHANGELOG.md updated --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 549ebfc..49a0588 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- CLI messages updated +- CLI modified ## [0.8] - 2026-02-05 ### Added - Support [wtfismyip.com](https://wtfismyip.com/json) IPv6 API From f80aaa5bbc6e45f03a94d894d73b4badfb5b2fc7 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 14 Feb 2026 18:53:53 +0330 Subject: [PATCH 6/6] fix : minor issue in main fixed --- ipspot/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipspot/cli.py b/ipspot/cli.py index 7c2a504..e76409b 100644 --- a/ipspot/cli.py +++ b/ipspot/cli.py @@ -149,7 +149,7 @@ def _run(args: argparse.Namespace) -> None: # pragma: no cover def main() -> None: # pragma: no cover """CLI main function.""" try: - args = parse_args() - run(args) + args = _parse_args() + _run(args) except (KeyboardInterrupt, EOFError): print(EXIT_MESSAGE)