forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorManagementWorkflow.php
70 lines (58 loc) · 1.54 KB
/
PhabricatorManagementWorkflow.php
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
<?php
abstract class PhabricatorManagementWorkflow extends PhutilArgumentWorkflow {
public function isExecutable() {
return true;
}
public function getViewer() {
// Some day, we might provide a more general viewer mechanism to scripts.
// For now, workflows can call this method for convenience and future
// flexibility.
return PhabricatorUser::getOmnipotentUser();
}
protected function parseTimeArgument($time) {
if (!strlen($time)) {
return null;
}
$epoch = strtotime($time);
if ($epoch <= 0) {
throw new PhutilArgumentUsageException(
pht('Unable to parse time "%s".', $time));
}
return $epoch;
}
protected function newContentSource() {
return PhabricatorContentSource::newForSource(
PhabricatorConsoleContentSource::SOURCECONST);
}
protected function logInfo($label, $message) {
$this->logRaw(
tsprintf(
"**<bg:blue> %s </bg>** %s\n",
$label,
$message));
}
protected function logOkay($label, $message) {
$this->logRaw(
tsprintf(
"**<bg:green> %s </bg>** %s\n",
$label,
$message));
}
protected function logWarn($label, $message) {
$this->logRaw(
tsprintf(
"**<bg:yellow> %s </bg>** %s\n",
$label,
$message));
}
protected function logFail($label, $message) {
$this->logRaw(
tsprintf(
"**<bg:red> %s </bg>** %s\n",
$label,
$message));
}
private function logRaw($message) {
fprintf(STDERR, '%s', $message);
}
}