-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
54 lines (41 loc) · 1.46 KB
/
__main__.py
File metadata and controls
54 lines (41 loc) · 1.46 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
import sys
import getopt
import codeInjector.context
from html5.actions import Html5AppAction
configArguments = ['branch=', 'version=', 'env=', "job=", "app="]
def getConfigArguments():
return configArguments[:]
class ArgumentProcessor:
def processArguments(self, argv):
try:
opts, args = getopt.getopt(argv, "", configArguments)
except getopt.GetoptError:
print('invalid arguments expecting:{expected}'.format(
expected=" ".join(configArguments)))
sys.exit(2)
for opt, arg in opts:
if opt == '--branch':
self.branch = arg
elif opt == '--version':
self.version = arg
elif opt == '--env':
self.env = arg
elif opt == "--job":
self.job = arg
elif opt == '--app':
self.app = arg
else:
print('invalid arguments expecting:{expected}'.format(
expected=" ".join(configArguments)))
codeInjector.context.createApp(
self.app, self.branch, self.version, self.env)
def execute(self):
if self.app == 'html5':
html5AppAction = Html5AppAction(self.job)
html5AppAction.execute()
def main(argv):
argumentProcessor = ArgumentProcessor()
argumentProcessor.processArguments(argv)
argumentProcessor.execute()
if __name__ == "__main__":
main(sys.argv[1:])