mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-04-11 11:58:32 +02:00
Test Plan: Ran `phpstan analyze -a autoload.php arcanist/src` with `autoload.php` containing: <?php require_once 'libphutil/src/__phutil_library_init__.php'; require_once 'arcanist/src/__phutil_library_init__.php'; Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17367
111 lines
2.5 KiB
PHP
111 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Stop time tracking on an object.
|
|
*/
|
|
final class ArcanistStopWorkflow extends ArcanistPhrequentWorkflow {
|
|
|
|
public function getWorkflowName() {
|
|
return 'stop';
|
|
}
|
|
|
|
public function getCommandSynopses() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
**stop** [--note __note__] [__objects__]
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function getCommandHelp() {
|
|
return phutil_console_format(<<<EOTEXT
|
|
Stop tracking work in Phrequent.
|
|
EOTEXT
|
|
);
|
|
}
|
|
|
|
public function requiresConduit() {
|
|
return true;
|
|
}
|
|
|
|
public function requiresAuthentication() {
|
|
return true;
|
|
}
|
|
|
|
public function getArguments() {
|
|
return array(
|
|
'note' => array(
|
|
'param' => 'note',
|
|
'help' => pht('A note to attach to the tracked time.'),
|
|
),
|
|
'*' => 'name',
|
|
);
|
|
}
|
|
|
|
public function run() {
|
|
$conduit = $this->getConduit();
|
|
$names = $this->getArgument('name');
|
|
|
|
$object_lookup = $conduit->callMethodSynchronous(
|
|
'phid.lookup',
|
|
array(
|
|
'names' => $names,
|
|
));
|
|
|
|
foreach ($names as $object_name) {
|
|
if (!array_key_exists($object_name, $object_lookup)) {
|
|
throw new ArcanistUsageException(
|
|
pht("No such object '%s' found.", $object_name));
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
if (count($names) === 0) {
|
|
// Implicit stop; add an entry so the loop will call
|
|
// `phrequent.pop` with a null `objectPHID`.
|
|
$object_lookup[] = array('phid' => null);
|
|
}
|
|
|
|
$stopped_phids = array();
|
|
foreach ($object_lookup as $ref) {
|
|
$object_phid = $ref['phid'];
|
|
|
|
$stopped_phid = $conduit->callMethodSynchronous(
|
|
'phrequent.pop',
|
|
array(
|
|
'objectPHID' => $object_phid,
|
|
'note' => $this->getArgument('note'),
|
|
));
|
|
if ($stopped_phid !== null) {
|
|
$stopped_phids[] = $stopped_phid;
|
|
}
|
|
}
|
|
|
|
if (count($stopped_phids) === 0) {
|
|
if (count($names) === 0) {
|
|
echo phutil_console_format(
|
|
"%s\n",
|
|
pht('Not currently tracking time against any object.'));
|
|
} else {
|
|
echo phutil_console_format(
|
|
"%s\n",
|
|
pht(
|
|
'Not currently tracking time against %s.',
|
|
implode(', ', ipull($object_lookup, 'fullName'))));
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
$phid_query = $conduit->callMethodSynchronous(
|
|
'phid.query',
|
|
array(
|
|
'phids' => $stopped_phids,
|
|
));
|
|
|
|
echo phutil_console_format(
|
|
"%s %s\n\n",
|
|
pht('Stopped:'),
|
|
implode(', ', ipull($phid_query, 'fullName')));
|
|
$this->printCurrentTracking();
|
|
}
|
|
|
|
}
|