#!/usr/bin/env php getAvailableDatasets(); function _printf(string $fmt, ...$args): void { $out = sprintf($fmt, ...$args); if (!posix_isatty(STDOUT)) { $out = preg_replace("<\e\\[[0-9;]+m>", "", $out); } echo $out; } foreach ($datasets as $dataset) { _printf("Identifier: \e[36m%s\e[35m#\e[36;1m%s\e[0m\n", $dataset->getPackageName(), $dataset->getDatasetName()); // $dataset->getIdentifier()."\n"; _printf(" Package: \e[33m%s\e[0m\n", $dataset->getPackageName()); _printf(" Dataset: \e[33m%s\e[0m\n", $dataset->getDatasetName()); _printf(" Version: \e[33m%s\e[0m\n", $dataset->getVersion()); $reader = $dataset->open(); $rows = 0; $headers = null; foreach ($reader as $row) { if (!$headers) $headers = array_keys($row); $rows++; } _printf(" Rows: \e[33m%d\e[0m\n", $rows); _printf(" Fields: \e[32;1m%s\e[0m\n", join("\e[0m\n \e[32;1m",$headers)); }