From 3267e6a245ab599d376f3fee402130d072abe5ce Mon Sep 17 00:00:00 2001 From: samedamci Date: Mon, 23 Aug 2021 11:57:18 +0200 Subject: [PATCH] Add simple CLI --- gitfiler/__main__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 gitfiler/__main__.py diff --git a/gitfiler/__main__.py b/gitfiler/__main__.py new file mode 100644 index 0000000..78116ec --- /dev/null +++ b/gitfiler/__main__.py @@ -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)