Allow selection of interpreter

Closes #5
Closes #7
This commit is contained in:
Samuel Sloniker 2022-04-08 13:25:20 -07:00
parent 92ad9bfa6b
commit 3d985edb5a

View File

@ -2,6 +2,7 @@ import requests
import subprocess import subprocess
import sys import sys
import argparse import argparse
import shlex
def launch(command, data): def launch(command, data):
@ -38,11 +39,22 @@ parser.add_argument(
action="store_true", action="store_true",
help="Skip pager and confirmation; run script immediately", help="Skip pager and confirmation; run script immediately",
) )
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() args = parser.parse_args()
url = args.url url = args.url
pager = shlex.split(args.pager)
interpreter = ["bash"] interpreter = shlex.split(args.interpreter)
pager = ["less"]
content = requests.get(url).content content = requests.get(url).content
@ -53,6 +65,7 @@ else:
response = yn("Do you want to run this script?") response = yn("Do you want to run this script?")
if response == "y": if response == "y":
print("=" * 20)
launch(interpreter, content) launch(interpreter, content)
else: else:
print("Script not run.") print("Script not run.")