2022-06-25 22:27:01 +01:00
|
|
|
#!/usr/local/env python3
|
|
|
|
|
|
|
|
"""MODULE: Provides CLI arguments to the application."""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
2025-01-17 00:30:00 +01:00
|
|
|
from app.query_normalisation import get_public_ip
|
2022-06-25 22:27:01 +01:00
|
|
|
|
|
|
|
|
2022-07-10 17:27:44 +01:00
|
|
|
def parse_args() -> argparse.Namespace: # pragma: no cover
|
2024-04-27 18:28:14 +01:00
|
|
|
"""Get arguments from user via the command line.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
None
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
argparse.Namespace: parsed arguments
|
|
|
|
"""
|
2022-06-25 22:27:01 +01:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="Query information about an IP address or domain name."
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-q",
|
|
|
|
"--query",
|
|
|
|
help="IP/domain name to query (default: current public IP)",
|
|
|
|
default=get_public_ip(),
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-p",
|
|
|
|
"--prefixes",
|
|
|
|
help="show advertised prefixes",
|
|
|
|
action="store_true",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-n",
|
|
|
|
"--noheader",
|
|
|
|
help="do not print header",
|
|
|
|
action="store_true",
|
|
|
|
)
|
|
|
|
return parser.parse_args()
|