Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions inc/Cli/Commands/WorkspaceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use DataMachine\Cli\BaseCommand;
use DataMachineCode\Cli\CliResponseRenderer;
use DataMachineCode\Cli\CliRepeatableOptionParser;
use DataMachineCode\Cli\WorkspaceCompactOutput;
use DataMachineCode\Cleanup\CompositeCleanupRunEvidenceStore;
use DataMachineCode\Cleanup\CleanupRunEvidenceStoreInterface;
use DataMachineCode\Workspace\Workspace;
Expand Down Expand Up @@ -1247,7 +1248,7 @@ private function render_cleanup_run_status( string $run_id, array $assoc_args, b
return;
}

$this->render_cleanup_control_result($output, $assoc_args);
$this->render_cleanup_control_result($output, $assoc_args, $evidence);
}

private function cleanup_run_evidence_store(): CleanupRunEvidenceStoreInterface {
Expand Down Expand Up @@ -1321,13 +1322,16 @@ private function cleanup_run_control_job_ids( string $operation, int $job_id ):
return array_values(array_unique(array_filter(array_merge(array( $job_id ), $pending_ids, $processing_ids))));
}

private function render_cleanup_control_result( array $result, array $assoc_args ): void {
private function render_cleanup_control_result( array $result, array $assoc_args, bool $full_evidence = false ): void {
$result = $this->attach_current_workspace_lock_status($result);
$format = (string) ( $assoc_args['format'] ?? 'table' );
if ( ! empty($assoc_args['summary']) ) {
$result = $this->build_cleanup_operator_summary($result);
}
if ( 'json' === $format ) {
if ( empty($assoc_args['verbose']) && empty($assoc_args['summary']) && ! $full_evidence ) {
$result = WorkspaceCompactOutput::cleanup_control_result($result);
}
$this->renderer()->json($result);
return;
}
Expand Down Expand Up @@ -4399,6 +4403,9 @@ function ( $wt ) {
*/
private function render_workspace_lock_result( array $result, array $assoc_args, bool $prune ): void {
if ( 'json' === (string) ( $assoc_args['format'] ?? '' ) ) {
if ( empty($assoc_args['verbose']) ) {
$result = WorkspaceCompactOutput::lock_result($result);
}
$this->renderer()->json($result);
return;
}
Expand Down Expand Up @@ -4638,6 +4645,9 @@ private function resolve_owner_context_session_id( array $owner_context ): strin
private function render_workspace_hygiene_report( array $report, array $assoc_args ): void {
$format = isset($assoc_args['format']) ? (string) $assoc_args['format'] : 'table';
if ( 'json' === $format ) {
if ( empty($assoc_args['verbose']) ) {
$report = WorkspaceCompactOutput::hygiene_report($report);
}
$this->renderer()->json($report);
return;
}
Expand Down Expand Up @@ -4898,6 +4908,9 @@ private function render_worktree_cleanup_result( array $result, array $assoc_arg
$report = $this->filter_worktree_cleanup_report($result, $only);

if ( 'json' === $format ) {
if ( empty($assoc_args['verbose']) ) {
$report = WorkspaceCompactOutput::cleanup_result($report);
}
$this->renderer()->json($report);
return;
}
Expand Down Expand Up @@ -5783,6 +5796,9 @@ private function render_worktree_active_no_signal_remote_clean_apply_result( arr
private function render_worktree_artifact_cleanup_result( array $result, array $assoc_args ): void {
$format = isset($assoc_args['format']) ? (string) $assoc_args['format'] : 'table';
if ( 'json' === $format ) {
if ( empty($assoc_args['verbose']) ) {
$result = WorkspaceCompactOutput::cleanup_result($result);
}
$this->renderer()->json($result);
return;
}
Expand Down Expand Up @@ -6084,6 +6100,9 @@ private function render_worktree_bounded_cleanup_eligible_apply_result( array $r
*/
private function render_worktree_cleanup_eligible_drain_result( array $result, array $assoc_args ): void {
if ( 'json' === (string) ( $assoc_args['format'] ?? '' ) ) {
if ( empty($assoc_args['verbose']) ) {
$result = WorkspaceCompactOutput::cleanup_result($result);
}
$this->renderer()->json($result);
return;
}
Expand Down Expand Up @@ -6448,6 +6467,9 @@ private function compact_cleanup_row( array $row ): array {
private function render_worktree_emergency_cleanup_result( array $result, array $assoc_args ): void {
$format = isset($assoc_args['format']) ? (string) $assoc_args['format'] : 'table';
if ( 'json' === $format ) {
if ( empty($assoc_args['verbose']) ) {
$result = WorkspaceCompactOutput::cleanup_result($result);
}
$this->renderer()->json($result);
return;
}
Expand Down
Loading
Loading