Add simple CLI

This commit is contained in:
samedamci 2021-08-23 11:57:18 +02:00
parent 5ebc143947
commit 3267e6a245
No known key found for this signature in database
GPG Key ID: FCB4A9A20D00E894

20
gitfiler/__main__.py Normal file
View File

@ -0,0 +1,20 @@
import argparse
import sys
from . import gitfiler
from .exceptions import InvalidURL, UnsupportedURL
parser = argparse.ArgumentParser(
prog="gitfiler",
description="GitHub/GitLab single file downloader.",
allow_abbrev=False,
)
parser.add_argument(dest="URL")
args = parser.parse_args()
try:
file_ = gitfiler(args.URL)
file_content = file_.text
print(file_content)
except (InvalidURL, UnsupportedURL) as e:
print(f"{parser.prog}: error: {e}")
sys.exit(1)