Add --quiet

This commit is contained in:
Samuel Sloniker 2022-04-08 14:17:01 -07:00
parent 3e3c44075a
commit d8c3cd2e36

View File

@ -54,17 +54,25 @@ group.add_argument(
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",
)
args = parser.parse_args()
url = args.url
pager = shlex.split(args.pager)
interpreter = shlex.split(args.interpreter)
print(f"Downloading `{url}`...")
if not args.quiet:
print(f"Downloading `{url}`...")
content = requests.get(url).content
print("Download successful.")
print("=" * os.get_terminal_size().columns)
if not args.quiet:
print("Download successful.")
print("=" * os.get_terminal_size().columns)
if args.skip_pager:
if args.skip_pager or args.quiet:
launch(interpreter, content)
else:
launch(pager, content)