-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhqml.py
More file actions
63 lines (49 loc) · 1.81 KB
/
hqml.py
File metadata and controls
63 lines (49 loc) · 1.81 KB
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
58
59
60
61
62
63
#!/usr/bin/python3
import argparse
def dir_path(string):
import os
if os.path.isdir(string):
return string
else:
raise NotADirectoryError(string)
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected.')
def build_argparser():
parser = argparse.ArgumentParser(prog="hqml")
subparsers = parser.add_subparsers(dest='function', help='help for subcommand')
# create the parser for the "command_1" command
parser_a = subparsers.add_parser('create', help='create project')
parser_a.add_argument('path', help='target path')
# create the parser for the "command_2" command
parser_b = subparsers.add_parser('build', help='build project')
parser_c = subparsers.add_parser('config', help='configure project settings')
parser_c.add_argument('--hot-reload', type=str2bool, help='hot reload')
parser_d = subparsers.add_parser('update', help='update hqml')
return parser
def main():
import sys
parser = build_argparser()
if len(sys.argv) == 1:
parser.print_usage()
args = parser.parse_args()
if args.function == 'create':
from create_project import create_project
create_project(args.path)
if args.function == 'build':
from build_project import build_project
build_project()
if args.function == "config":
if args.hot_reload != None:
print(args.hot_reload)
else:
print('Nothing to configure')
if args.function == 'update':
from version_control import update
update()