from argparse import ArgumentParser
+import requests
def command_line_parser() -> ArgumentParser:
parser = ArgumentParser(prog='paperdoorknob', description='Print glowfic')
+ parser.add_argument(
+ '--timeout',
+ help='How long to wait for HTTP requests, in seconds',
+ default=30)
+ parser.add_argument('url', help='URL to retrieve')
return parser
+def fetch(url: str, timeout: int) -> None:
+ r = requests.get(url, timeout=timeout)
+ r.raise_for_status()
+
+
def main() -> None:
- command_line_parser().parse_args()
+ args = command_line_parser().parse_args()
+ fetch(args.url, args.timeout)
if __name__ == '__main__':