diff --git a/src/workflow/ArcanistTodoWorkflow.php b/src/workflow/ArcanistTodoWorkflow.php --- a/src/workflow/ArcanistTodoWorkflow.php +++ b/src/workflow/ArcanistTodoWorkflow.php @@ -37,15 +37,19 @@ return true; } - public function getArguments() { return array( '*' => 'summary', 'cc' => array( - 'param' => 'cc', - 'short' => 'C', + 'param' => 'cc', + 'short' => 'C', + 'repeat' => true, + 'help' => pht('Other users to CC on the new task.'), + ), + 'project' => array( + 'param' => 'project', 'repeat' => true, - 'help' => 'Other users to CC on the new task.', + 'help' => pht('Projects to assign to the task.'), ), ); } @@ -53,6 +57,8 @@ public function run() { $summary = implode(' ', $this->getArgument('summary')); $ccs = $this->getArgument('cc'); + $slugs = $this->getArgument('project'); + $conduit = $this->getConduit(); if (trim($summary) == '') { @@ -62,7 +68,7 @@ $args = array( 'title' => $summary, - 'ownerPHID' => $this->getUserPHID() + 'ownerPHID' => $this->getUserPHID(), ); if ($ccs) { @@ -70,7 +76,7 @@ $users = $conduit->callMethodSynchronous( 'user.query', array( - 'usernames' => $ccs + 'usernames' => $ccs, )); foreach ($users as $user => $info) { $phids[] = $info['phid']; @@ -78,6 +84,29 @@ $args['ccPHIDs'] = $phids; } + if ($slugs) { + $phids = array(); + $project_slugs = array(); + $projects = $conduit->callMethodSynchronous( + 'project.query', + array( + 'slugs' => $slugs, + )); + + foreach ($projects as $project) { + $phids[] = $project['phid']; + $project_slugs = array_merge($project_slugs, $project['slugs']); + } + + foreach ($slugs as $slug) { + if (!in_array($slug, $project_slugs)) { + throw new ArcanistUsageException('No such project: "'.$slug.'"'); + } + } + + $args['projectPHIDs'] = $phids; + } + $result = $conduit->callMethodSynchronous( 'maniphest.createtask', $args);