From a3eba05f82d65343252bb6f085f0957e919d027e Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Fri, 8 Apr 2022 12:35:45 -0700 Subject: [PATCH] Use argparse Closes #2 --- README.md | 3 +-- netrun.py | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f0b800f..8897906 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ running `curl | bash` ## Work in Progress `netrun` is still experimental; don't rely on its working properly. In -particular, HTTP response codes are ignored (see #1) and command line syntax is -not checked (see #2). +particular, HTTP response codes are ignored (see #1). ## Try it diff --git a/netrun.py b/netrun.py index a99ef3f..e3fc861 100644 --- a/netrun.py +++ b/netrun.py @@ -1,6 +1,7 @@ import requests import subprocess import sys +import argparse def launch(command, data): @@ -26,8 +27,10 @@ def yn(question, options="yn"): return response - -url = sys.argv[1] +parser = argparse.ArgumentParser(description="Securely run a script from the Internet") +parser.add_argument("url", help="URL of the script") +args = parser.parse_args() +url = args.url content = requests.get(url).content