Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14401620
D8938.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8938.diff
View Options
diff --git a/src/workflow/ArcanistCloseWorkflow.php b/src/workflow/ArcanistCloseWorkflow.php
--- a/src/workflow/ArcanistCloseWorkflow.php
+++ b/src/workflow/ArcanistCloseWorkflow.php
@@ -8,15 +8,28 @@
final class ArcanistCloseWorkflow extends ArcanistBaseWorkflow {
private $tasks;
- private $statusOptions = array(
- "resolved" => 1,
- "wontfix" => 2,
- "invalid" => 3,
- "duplicate" => 4,
- "spite" => 5,
- "open" => 0
- );
+ private $statusOptions;
+ private $statusData;
+
+ private function loadStatusData() {
+ $this->statusData = $this->getConduit()->callMethodSynchronous(
+ 'maniphest.querystatuses',
+ array());
+ return $this;
+ }
+ private function getStatusOptions() {
+ if ($this->statusData === null) {
+ throw new Exception('loadStatusData first!');
+ }
+ return idx($this->statusData, 'statusMap');
+ }
+ private function getDefaultClosedStatus() {
+ if ($this->statusData === null) {
+ throw new Exception('loadStatusData first!');
+ }
+ return idx($this->statusData, 'defaultClosedStatus');
+ }
public function getWorkflowName() {
return 'close';
@@ -31,7 +44,7 @@
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
- Close a task.
+ Close a task or otherwise update its status.
EOTEXT
);
}
@@ -50,37 +63,45 @@
public function getArguments() {
- $options = array_keys($this->statusOptions);
- $last = array_pop($options);
return array(
'*' => 'task_id',
'message' => array(
'short' => 'm',
'param' => 'comment',
- 'help' => "Provide a comment with your status change.",
+ 'help' => pht('Provide a comment with your status change.'),
),
'status' => array(
'param' => 'status',
'short' => 's',
- 'help' => "New status. Valid options are ".
- implode(', ', $options).", or {$last}. Default is resolved.\n"
+ 'help' => pht('Specify a new status. Valid status options can be '.
+ 'seen with the `list-statuses` argument.'),
+ ),
+ 'list-statuses' => array(
+ 'help' => 'Show available status options and exit.',
),
);
}
public function run() {
+ $this->loadStatusData();
+ $list_statuses = $this->getArgument('list-statuses');
+ if ($list_statuses) {
+ echo phutil_console_format(pht(
+ "Valid status options are:\n".
+ "\t%s\n", implode($this->getStatusOptions(), ', ')));
+ return 0;
+ }
$ids = $this->getArgument('task_id');
$message = $this->getArgument('message');
$status = strtolower($this->getArgument('status'));
+ $status_options = $this->getStatusOptions();
if (!isset($status) || $status == '') {
- $status = head_key($this->statusOptions);
+ $status = $this->getDefaultClosedStatus();
}
- if (isset($this->statusOptions[$status])) {
- $status = $this->statusOptions[$status];
- } else {
- $options = array_keys($this->statusOptions);
+ if (!isset($status_options[$status])) {
+ $options = array_keys($status_options);
$last = array_pop($options);
echo "Invalid status {$status}, valid options are ".
implode(', ', $options).", or {$last}.\n";
@@ -94,7 +115,6 @@
}
$id = ltrim($id, 'T');
$result = $this->closeTask($id, $status, $message);
- $status_options = array_flip($this->statusOptions);
$current_status = $status_options[$status];
if ($result) {
echo "T{$id}'s status is now set to {$current_status}.\n";
@@ -105,7 +125,7 @@
return 0;
}
- private function closeTask($task_id, $status = 1, $comment = "") {
+ private function closeTask($task_id, $status, $comment = "") {
$conduit = $this->getConduit();
$info = $conduit->callMethodSynchronous(
'maniphest.info',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 10:27 PM (10 h, 2 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6922239
Default Alt Text
D8938.diff (3 KB)
Attached To
Mode
D8938: Arcanst - add support for custom statuses to `arc close` workflow
Attached
Detach File
Event Timeline
Log In to Comment