From 1f65a115cc7effb8de84583b938f9303b0ff891f Mon Sep 17 00:00:00 2001 From: Alan Huang Date: Tue, 10 Jul 2012 17:32:36 -0700 Subject: [PATCH] Create an arc todo workflow for quickly creating a task. Summary: Run `arc todo o rly?` to create a Maniphest task titled 'o rly?'. Pass --cc to add CCs besides yourself. Test Plan: Ran `arc todo o rly?`. Behaved as expected. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T749, T1325 Differential Revision: https://secure.phabricator.com/D2952 --- src/__phutil_library_map__.php | 2 + src/workflow/ArcanistTodoWorkflow.php | 98 +++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 src/workflow/ArcanistTodoWorkflow.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index fdfda1a8..7af9c2e0 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -112,6 +112,7 @@ phutil_register_library_map(array( 'ArcanistTasksWorkflow' => 'workflow/ArcanistTasksWorkflow.php', 'ArcanistTextLinter' => 'lint/linter/ArcanistTextLinter.php', 'ArcanistTextLinterTestCase' => 'lint/linter/__tests__/ArcanistTextLinterTestCase.php', + 'ArcanistTodoWorkflow' => 'workflow/ArcanistTodoWorkflow.php', 'ArcanistUncommittedChangesException' => 'exception/usage/ArcanistUncommittedChangesException.php', 'ArcanistUnitTestResult' => 'unit/ArcanistUnitTestResult.php', 'ArcanistUnitWorkflow' => 'workflow/ArcanistUnitWorkflow.php', @@ -213,6 +214,7 @@ phutil_register_library_map(array( 'ArcanistTasksWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistTextLinter' => 'ArcanistLinter', 'ArcanistTextLinterTestCase' => 'ArcanistLinterTestCase', + 'ArcanistTodoWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistUncommittedChangesException' => 'ArcanistUsageException', 'ArcanistUnitWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistUpgradeWorkflow' => 'ArcanistBaseWorkflow', diff --git a/src/workflow/ArcanistTodoWorkflow.php b/src/workflow/ArcanistTodoWorkflow.php new file mode 100644 index 00000000..a600c373 --- /dev/null +++ b/src/workflow/ArcanistTodoWorkflow.php @@ -0,0 +1,98 @@ + '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; + } + + $conduit->callMethodSynchronous( + 'maniphest.createtask', + $args); + } + +} -- 2.43.0