This repository was archived by the owner on Dec 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstack.php
More file actions
65 lines (52 loc) · 1.29 KB
/
stack.php
File metadata and controls
65 lines (52 loc) · 1.29 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
64
65
#!/usr/bin/env php
<?php
/// @todo add support for --docker=/path/to/docker
/// @todo add support for other options, such as verbose mode
require('src/Builder.php');
function help() {
echo "
Usage: stack.php <action>
valid actions: build, run, stop, update, ps
";
exit;
}
// *** live code starts here ***
if ($argc < 2 || $argv[1] == '-h' || $argv[1] == '--help') {
help();
}
/*if ($argc < 3 || $argv[2] == 'all') {
$images = Builder::getImages();
} else {
$image = $argv[2];
if (!Builder::hasImage($image)) {
throw new \Exception("Unknown image: '$image'");
}
$images = array($image);
}*/
switch($argv[1]) {
case 'build':
// q: do we really have to always remove images before a build?
Builder::stop(true);
Builder::build();
break;
case 'run':
case 'start':
Builder::run();
echo "\n" . implode("\n", Builder::ps()) . "\n";
break;
case 'stop':
Builder::stop();
break;
case 'update':
Builder::stop();
Builder::update();
Builder::build();
Builder::run();
echo "\n" . implode("\n", Builder::ps()) . "\n";
break;
case 'ps':
echo implode("\n", Builder::ps()) . "\n";
break;
default:
help();
}