diff --git a/cli/clickup-task.php b/cli/clickup-task.php index 9293078..dd1a053 100755 --- a/cli/clickup-task.php +++ b/cli/clickup-task.php @@ -1,48 +1,53 @@ #!/usr/bin/php ClickUp bot # Copyright (C) 2023 Valerio Bozzolan, contributors # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . /** * Get ClickUp Task info * * If you specify also a Phabricator Task ID, it connects both. */ // autoload libraries require __DIR__ . '/../autoload.php'; $clickup_task_id = $argv[1] ?? null; $phab_task_id = $argv[2] ?? null; if( !$clickup_task_id ) { echo "RTFM\n"; exit; } $clickup_task_details = ClickUpAPI::queryTaskData( $clickup_task_id ); -echo json_encode( $clickup_task_details, JSON_PRETTY_PRINT ); +print_r( $clickup_task_details ); echo "\n"; if( $phab_task_id ) { $phab_task_details = PhabricatorAPI::getTask( $phab_task_id ); - ClickUpPhabricatorCache::instance()->newlock()->registerClickupPhabricatorTaskID( $clickup_task_id, $phab_task_details )->save(); + if( $phab_task_details ) { + $phab_task_id = $phab_task_details['id']; + if( $phab_task_details['type'] === 'TASK' ) { + ClickUpPhabricatorCache::instance()->newlock()->registerClickupPhabricatorTaskID( $clickup_task_id, $phab_task_id )->save(); + } + } - echo json_encode( $phab_task_details, JSON_PRETTY_PRINT ); + print_r( $phab_task_details ); echo "\n"; }