-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunCommand.php
More file actions
84 lines (75 loc) · 1.86 KB
/
RunCommand.php
File metadata and controls
84 lines (75 loc) · 1.86 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
namespace Gt\Build\Cli;
use Gt\Build\BuildRunner;
use Gt\Cli\Argument\ArgumentValueList;
use Gt\Cli\Command\Command;
use Gt\Cli\Parameter\NamedParameter;
use Gt\Cli\Parameter\Parameter;
class RunCommand extends Command {
public function run(?ArgumentValueList $arguments = null):int {
$path = getcwd();
if($arguments->contains("config")) {
$path = (string)$arguments->get("config");
}
$buildRunner = new BuildRunner($path, $this->stream);
if($arguments->contains("default")) {
$buildRunner->setDefaultPath($arguments->get("default"));
}
$mode = null;
if($arguments->contains("mode")) {
$mode = (string)$arguments->get("mode");
}
$buildRunner->run(
$arguments->contains("watch"),
$mode,
);
return 0;
}
public function getName():string {
return "run";
}
public function getDescription():string {
return "Compile client-side assets";
}
/** @return NamedParameter[] */
public function getRequiredNamedParameterList():array {
return [];
}
/** @return NamedParameter[] */
public function getOptionalNamedParameterList():array {
return [];
}
/** @return Parameter[] */
public function getRequiredParameterList():array {
return [];
}
/** @return Parameter[] */
public function getOptionalParameterList():array {
return [
new Parameter(
false,
"watch",
"w",
"Pass this flag to continue the build runner after first build. Any changes to the filesystem will be rebuilt automatically."
),
new Parameter(
true,
"config",
"c",
"Path to the build.json. This defaults to the project root directory."
),
new Parameter(
true,
"default",
"d",
"Path to a default build.json to use if there is no build.json in the project root."
),
new Parameter(
true,
"mode",
"m",
"Which version of build.json to build (e.g. production/development)."
),
];
}
}