Add simple CLI
This commit is contained in:
parent
5ebc143947
commit
3267e6a245
20
gitfiler/__main__.py
Normal file
20
gitfiler/__main__.py
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user