-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.py
executable file
·65 lines (53 loc) · 2.2 KB
/
box.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
#!/usr/bin/env python
import sys
from settings import VALID_DATA_TYPES
from emerald import help
from emerald import add_model
from emerald import install_package
from emerald import add_controller
if len(sys.argv) > 1:
sysinput = sys.argv[1].lower()
if sysinput == '--help' or sysinput == '-h':
help()
elif sysinput == '--add' or sysinput == '-a':
if len(sys.argv) > 3:
install_package(sys.argv[2], sys.argv[3])
else:
print "You need to specify a valid package name"
sys.exit()
elif sysinput == '--initiate' or sysinput == '-i':
if len(sys.argv) > 2 and not sys.argv[2].isdigit():
add_controller(sys.argv[2])
else:
print 'Controller name can not be a number'
sys.exit()
elif sysinput == '--new' or sysinput == '-n':
if len(sys.argv) > 2:
model_name = sys.argv[2].title()
raw_component = sys.argv[3:]
model_components = []
if raw_component:
for component in raw_component:
raw_field = component.split(':')
field_name = raw_field[0]
detail_components = raw_field[1].split('--')
if detail_components[0].lower() in VALID_DATA_TYPES:
insert_components = {
'field_name': field_name,
'field_property': detail_components
}
else:
print '\n' + detail_components[0].lower() + ' is not a valid data type.'
sys.exit()
model_components.append(insert_components)
add_model(model_name, model_components)
else:
print '\nNot enough parameters are provided. Model requires field definitions. See box.py -h for info\n'
sys.exit()
else:
print '\nNot enough parameters are provided. See box.py -h for info\n'
else:
print '\nCommand not found. Please use --help for command options\n'
else:
print '\nNot enough parameters found. Please run box.py -h for complete explanations\n'
# end of file