Compare commits
No commits in common. "d8c3cd2e364a4c8c55c5290c64578d9eb31524a5" and "9f6ec508cec5b461684d845f134a95e90d6ffaa7" have entirely different histories.
d8c3cd2e36
...
9f6ec508ce
40
netrun.py
40
netrun.py
|
@ -2,7 +2,6 @@
|
|||
import requests
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import shlex
|
||||
|
||||
|
@ -36,51 +35,38 @@ parser = argparse.ArgumentParser(
|
|||
)
|
||||
parser.add_argument("url", help="URL of the script")
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--interpreter",
|
||||
help="Choose interpreter to use (default: `bash`)",
|
||||
default="bash",
|
||||
)
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument(
|
||||
"-p",
|
||||
"--pager",
|
||||
help="Choose pager to use (default: `less`)",
|
||||
default="less",
|
||||
)
|
||||
group.add_argument(
|
||||
"-s",
|
||||
"--skip-pager",
|
||||
action="store_true",
|
||||
help="Skip pager and confirmation; run script immediately",
|
||||
)
|
||||
group.add_argument(
|
||||
"-q",
|
||||
"--quiet",
|
||||
action="store_true",
|
||||
help="Skip pager and confirmation; run script immediately; do not print anything",
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--pager",
|
||||
help="Choose pager to use (default: `less`)",
|
||||
default="less",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--interpreter",
|
||||
help="Choose interpreter to use (default: `bash`)",
|
||||
default="bash",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
url = args.url
|
||||
pager = shlex.split(args.pager)
|
||||
interpreter = shlex.split(args.interpreter)
|
||||
|
||||
if not args.quiet:
|
||||
print(f"Downloading `{url}`...")
|
||||
content = requests.get(url).content
|
||||
if not args.quiet:
|
||||
print("Download successful.")
|
||||
print("=" * os.get_terminal_size().columns)
|
||||
|
||||
if args.skip_pager or args.quiet:
|
||||
if args.skip_pager:
|
||||
launch(interpreter, content)
|
||||
else:
|
||||
launch(pager, content)
|
||||
|
||||
response = yn("Do you want to run this script?")
|
||||
if response == "y":
|
||||
print("=" * os.get_terminal_size().columns)
|
||||
print("=" * 20)
|
||||
launch(interpreter, content)
|
||||
else:
|
||||
print("=" * os.get_terminal_size().columns)
|
||||
print("Script not run.")
|
||||
|
|
Loading…
Reference in New Issue
Block a user