2016-11-30 19:26:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorConfigManagementDoneWorkflow
|
|
|
|
extends PhabricatorConfigManagementWorkflow {
|
|
|
|
|
|
|
|
protected function didConstruct() {
|
|
|
|
$this
|
|
|
|
->setName('done')
|
|
|
|
->setExamples('**done** __activity__')
|
|
|
|
->setSynopsis(pht('Mark a manual upgrade activity as complete.'))
|
|
|
|
->setArguments(
|
|
|
|
array(
|
2016-12-01 20:19:36 +01:00
|
|
|
array(
|
|
|
|
'name' => 'force',
|
|
|
|
'short' => 'f',
|
|
|
|
'help' => pht(
|
|
|
|
'Mark activities complete even if there is no outstanding '.
|
|
|
|
'need to complete them.'),
|
|
|
|
),
|
2016-11-30 19:26:32 +01:00
|
|
|
array(
|
|
|
|
'name' => 'activities',
|
|
|
|
'wildcard' => true,
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(PhutilArgumentParser $args) {
|
2016-12-01 20:19:36 +01:00
|
|
|
$is_force = $args->getArg('force');
|
|
|
|
|
2016-11-30 19:26:32 +01:00
|
|
|
$activities = $args->getArg('activities');
|
|
|
|
if (!$activities) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
pht('Specify an activity to mark as completed.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($activities as $type) {
|
|
|
|
$activity = id(new PhabricatorConfigManualActivity())->loadOneWhere(
|
|
|
|
'activityType = %s',
|
|
|
|
$type);
|
|
|
|
if (!$activity) {
|
2016-12-01 20:19:36 +01:00
|
|
|
if ($is_force) {
|
|
|
|
echo tsprintf(
|
|
|
|
"%s\n",
|
|
|
|
pht(
|
|
|
|
'Activity "%s" did not need to be marked as complete.',
|
|
|
|
$type));
|
|
|
|
} else {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
pht(
|
|
|
|
'Activity "%s" is not currently marked as required, so there '.
|
|
|
|
'is no need to complete it.',
|
|
|
|
$type));
|
|
|
|
}
|
2016-11-30 19:26:32 +01:00
|
|
|
} else {
|
|
|
|
$activity->delete();
|
|
|
|
echo tsprintf(
|
|
|
|
"%s\n",
|
|
|
|
pht(
|
|
|
|
'Marked activity "%s" as completed.',
|
|
|
|
$type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo tsprintf(
|
|
|
|
"%s\n",
|
|
|
|
pht('Done.'));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|