-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.py
79 lines (59 loc) · 1.38 KB
/
build.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import sys
from subprocess import run
from tools.pdocs import console, pdoc3serve, pdoc3, shipDocs
HELP = """
python3 build.py command
command:
-h
--help
help : display help and exit
docs : serve docs locally
pdocs : build docs
sdocs : ship docs
ship msg : push repo and publish docs on GitHub
"""
ORG = "among"
REPO = "fusus"
PKG = "fusus"
def readArgs():
args = sys.argv[1:]
if not len(args) or args[0] in {"-h", "--help", "help"}:
console(HELP)
return (False, None, [])
arg = args[0]
if arg not in {
"docs",
"pdocs",
"sdocs",
"ship",
}:
console(HELP)
return (False, None, [])
if arg in {'ship'} and len(args) < 2:
console(HELP)
console("Provide a commit message")
return (False, None, [])
return (arg, None, [" ".join(args[1:])])
def ship(msg):
shipDocs(ORG, REPO, PKG)
pushrepo(msg)
def pushrepo(msg):
for cmdLine in (
"git add --all .",
f'''git commit -m "{msg}"''',
"git push origin master",
):
run(cmdLine, shell=True)
def main():
(task, msg, remaining) = readArgs()
if not task:
return
elif task == "docs":
pdoc3serve(PKG)
elif task == "pdocs":
pdoc3(PKG)
elif task == "sdocs":
shipDocs(ORG, REPO, PKG)
elif task == "ship":
ship(remaining[0])
main()