-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
30 lines (25 loc) · 982 Bytes
/
Copy pathcli.py
File metadata and controls
30 lines (25 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import argparse
import pathlib
loglevels = ["DEBUG", "INFO", "WARNING", "ERROR", 'CRITICAL']
def get_argparser() -> object:
parser = argparse.ArgumentParser(
"page_loader",
"page-loader --output /var/tmp https://ru.hexlet/courses",
"Allows you to load page with everything related to it")
parser.add_argument("url", help="webpage to download")
parser.add_argument(
'-o', "--output",
help="set destination path", default=pathlib.Path.cwd(), type=str)
parser.add_argument(
'-e', '--externals',
help="download external resources for this page.", action="store_true")
parser.add_argument(
'-x', help="open with webbrowser after download ends",
action="store_true")
parser.add_argument(
'-l', '--loglevel', help="set logging level",
default="INFO", choices=loglevels)
return parser
def parse_args() -> object:
args = get_argparser().parse_args()
return args