Index: src/__phutil_library_map__.php =================================================================== --- src/__phutil_library_map__.php +++ src/__phutil_library_map__.php @@ -147,6 +147,7 @@ 'ArcanistTextLinter' => 'lint/linter/ArcanistTextLinter.php', 'ArcanistTextLinterTestCase' => 'lint/linter/__tests__/ArcanistTextLinterTestCase.php', 'ArcanistTodoWorkflow' => 'workflow/ArcanistTodoWorkflow.php', + 'ArcanistTrackWorkflow' => 'workflow/ArcanistTrackWorkflow.php', 'ArcanistUncommittedChangesException' => 'exception/usage/ArcanistUncommittedChangesException.php', 'ArcanistUnitConsoleRenderer' => 'unit/renderer/ArcanistUnitConsoleRenderer.php', 'ArcanistUnitRenderer' => 'unit/renderer/ArcanistUnitRenderer.php', @@ -295,6 +296,7 @@ 'ArcanistTextLinter' => 'ArcanistLinter', 'ArcanistTextLinterTestCase' => 'ArcanistArcanistLinterTestCase', 'ArcanistTodoWorkflow' => 'ArcanistBaseWorkflow', + 'ArcanistTrackWorkflow' => 'ArcanistBaseWorkflow', 'ArcanistUncommittedChangesException' => 'ArcanistUsageException', 'ArcanistUnitConsoleRenderer' => 'ArcanistUnitRenderer', 'ArcanistUnitWorkflow' => 'ArcanistBaseWorkflow', Index: src/workflow/ArcanistTrackWorkflow.php =================================================================== --- /dev/null +++ src/workflow/ArcanistTrackWorkflow.php @@ -0,0 +1,115 @@ + array( + 'param' => 'T1234', + 'help' => "A maniphest task that you are working on.", + ), + 'start' => array( + 'help' => "Start tracking.", + ), + 'stop' => array( + 'help' => "Stop tracking.", + ) + ); + } + + public function run() { + $start_flag = $this->getArgument('start'); + $stop_flag = $this->getArgument('stop'); + + if (!$start_flag && !$stop_flag) { + echo "Please specify whether to --start or --stop tracking.\n"; + } + + $object_exists = false; + $object_id = null; + $object_name = ""; + $conduit = $this->getConduit(); + + if ($this->getArgument('task')) { + $object_exists = true; + + $id = $this->getArgument('task'); + if (!preg_match("/^T?\d+$/", $id)) { + echo "Invalid Task ID: {$id}.\n"; + return 1; + } + $id = ltrim($id, 'T'); + + $info = $conduit->callMethodSynchronous( + 'maniphest.info', + array( + 'task_id' => $id + )); + + $object_id = $info['phid']; + $object_name = "T$id: ".$info['title']; + } + + if (!$object_exists) { + echo "Please specify an object you are working on,"; + echo "like '--task T1234' for a task\n"; + return 1; + } + + $method_name = $start_flag ? "phrequent.start" : "phrequent.stop"; + + $info = $conduit->callMethodSynchronous( + $method_name, + array( + 'object' => $object_id + )); + + if ($start_flag) { + echo phutil_console_format( + "Started tracking time for **%s**\n", + $object_name); + } + else { + echo phutil_console_format( + "Stopped tracking time for **%s**\n", + $object_name); + } + } + +}