2012-07-10 17:32:36 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Quickly create a task
|
|
|
|
*
|
|
|
|
* @group workflow
|
|
|
|
*/
|
|
|
|
final class ArcanistTodoWorkflow extends ArcanistBaseWorkflow {
|
|
|
|
|
Make Arcanist workflow names explicit
Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.
Remove all the rules tying workflow names to class names through arcane incantations.
This has a very small performance cost in that we need to load every Workflow class every time now, but we don't hit __init__ and such anymore and it was pretty negligible on my machine (98ms vs 104ms or something).
Test Plan: Ran "arc help", "arc which", "arc diff", etc.
Reviewers: edward, vrana, btrahan
Reviewed By: edward
CC: aran, zeeg
Differential Revision: https://secure.phabricator.com/D3691
2012-10-17 08:35:03 -07:00
|
|
|
public function getWorkflowName() {
|
|
|
|
return 'todo';
|
|
|
|
}
|
|
|
|
|
2012-07-10 17:32:36 -07:00
|
|
|
public function getCommandSynopses() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
|
|
|
**todo** __summary__ [__options__]
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandHelp() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
|
|
|
Quickly create a task for yourself.
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresConduit() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function desiresWorkingCopy() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function requiresAuthentication() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
return array(
|
|
|
|
'*' => 'summary',
|
|
|
|
'cc' => array(
|
|
|
|
'param' => 'cc',
|
|
|
|
'short' => 'C',
|
|
|
|
'repeat' => true,
|
|
|
|
'help' => 'Other users to CC on the new task.',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run() {
|
|
|
|
$summary = implode(' ', $this->getArgument('summary'));
|
|
|
|
$ccs = $this->getArgument('cc');
|
|
|
|
$conduit = $this->getConduit();
|
|
|
|
|
|
|
|
if (trim($summary) == '') {
|
|
|
|
echo "Please provide a summary.\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$args = array(
|
|
|
|
'title' => $summary,
|
|
|
|
'ownerPHID' => $this->getUserPHID()
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($ccs) {
|
|
|
|
$phids = array();
|
|
|
|
$users = $conduit->callMethodSynchronous(
|
|
|
|
'user.query',
|
|
|
|
array(
|
|
|
|
'usernames' => $ccs
|
|
|
|
));
|
|
|
|
foreach ($users as $user => $info) {
|
|
|
|
$phids[] = $info['phid'];
|
|
|
|
}
|
|
|
|
$args['ccPHIDs'] = $phids;
|
|
|
|
}
|
|
|
|
|
2012-07-19 15:12:12 -07:00
|
|
|
$result = $conduit->callMethodSynchronous(
|
2012-07-10 17:32:36 -07:00
|
|
|
'maniphest.createtask',
|
|
|
|
$args);
|
2012-07-19 15:12:12 -07:00
|
|
|
|
|
|
|
echo phutil_console_format(
|
|
|
|
"Created task T%s: '<fg:green>**%s**</fg>' at <fg:blue>**%s**</fg>\n",
|
|
|
|
$result['id'],
|
|
|
|
$result['title'],
|
|
|
|
$result['uri']);
|
2012-07-10 17:32:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|