diff --git a/src/workflow/ArcanistTodoWorkflow.php b/src/workflow/ArcanistTodoWorkflow.php --- a/src/workflow/ArcanistTodoWorkflow.php +++ b/src/workflow/ArcanistTodoWorkflow.php @@ -35,15 +35,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.'), ), ); } @@ -51,6 +55,8 @@ public function run() { $summary = implode(' ', $this->getArgument('summary')); $ccs = $this->getArgument('cc'); + $slugs = $this->getArgument('project'); + $conduit = $this->getConduit(); if (trim($summary) == '') { @@ -60,7 +66,7 @@ $args = array( 'title' => $summary, - 'ownerPHID' => $this->getUserPHID() + 'ownerPHID' => $this->getUserPHID(), ); if ($ccs) { @@ -68,7 +74,7 @@ $users = $conduit->callMethodSynchronous( 'user.query', array( - 'usernames' => $ccs + 'usernames' => $ccs, )); foreach ($users as $user => $info) { $phids[] = $info['phid']; @@ -76,10 +82,27 @@ $args['ccPHIDs'] = $phids; } - $result = $conduit->callMethodSynchronous( - 'maniphest.createtask', - $args); + if ($slugs) { + $phids = array(); + $projects = $conduit->callMethodSynchronous( + 'project.query', + array( + 'slugs' => $slugs, + )); + + foreach ($slugs as $slug) { + $project = idx($projects['slugMap'], $slug); + + if (!$project) { + throw new ArcanistUsageException('No such project: "'.$slug.'"'); + } + $phids[] = $project; + } + + $args['projectPHIDs'] = $phids; + } + $result = $conduit->callMethodSynchronous('maniphest.createtask', $args); echo phutil_console_format( "Created task T%s: '**%s**' at **%s**\n", $result['id'],