forked from onlydustxyz/starklings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarklings.py
57 lines (47 loc) · 1.15 KB
/
starklings.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from argparse import ArgumentParser
import asyncio
import os
from pathlib import Path
from src import cli
script_root = Path(os.getcwd())
root_parser = ArgumentParser()
root_parser.add_argument(
"--version",
"-V",
default=False,
help="Show version-related data",
action="store_true",
)
root_parser.add_argument(
"--verify",
"-v",
default=False,
help="Verifies all exercises according to the recommended order",
action="store_true",
)
root_parser.add_argument(
"--watch",
"-w",
default=False,
help="Reruns `verify` when files were edited",
action="store_true",
)
def is_valid_file(parser, arg):
if not os.path.exists(arg):
parser.error(f"The file {arg} does not exist!")
else:
return Path(arg)
root_parser.add_argument(
"-s",
"--solution",
help="path to an exercise file",
type=lambda x: is_valid_file(root_parser, x),
)
try:
asyncio.run(cli(root_parser.parse_args(), script_root))
except Exception as error:
print(
"Unexpected Starklings error. Report it here:\n"
+ "https://github.com/onlydustxyz/starklings/issues\n"
)
raise error