-
Notifications
You must be signed in to change notification settings - Fork 1
/
laradock
executable file
·62 lines (45 loc) · 1.56 KB
/
laradock
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
#!/usr/bin/env python
import sys
from multienv.exceptions import HintMessageException
from multienv.multi_env import MultiEnv
from multienv.config import Config
def abort(error, hint=''):
"""
Abort execution.
Abort execution printing a message and a hint (optional).
Parameters:
error (str): The error message that will be shown
hint (str): A hint how to fix the error
Returns:
void
"""
print('ERROR: ' + error.strip())
if hint:
print('Hint: ' + hint.strip())
exit()
# Entry point
cmd = sys.argv[1] if len(sys.argv) > 1 else None
project_to_up = sys.argv[2] if len(sys.argv) > 2 else None
if not cmd:
abort(error='The first param with the command is required!',
hint='The unique available command is "up". E.g.: laradock up '
'project_name')
commands = ['up', 'exec']
if cmd not in commands:
abort(error='Invalid command "' + cmd + '"',
hint='You must choose one of these: [' +
', '.join(commands) + ']. E.g.: laradock up project_name')
if not project_to_up:
abort(error='The second param with the project name is required!')
try:
config = Config(dot_env='../.env',
env_var_container_build='config/env_var_container_build.yml',
projects='Projects.yml',
laradock_root_folder='..')
multi_env = MultiEnv(project_to_up, config)
if cmd == 'up':
multi_env.up()
elif cmd == 'exec':
multi_env.execute()
except HintMessageException as exc:
abort(error=exc.error, hint=exc.hint)