propresenter7-php-lib/bin/parse-macros.php
Thorsten Buss 4d10db4f17 Initial public release
PHP 8.4 library and CLI tools to read, modify, and generate ProPresenter 7
files: songs (.pro), playlists (.proplaylist), bundles (.probundle), themes,
and the global library files (Macros, Labels, Groups, ClearGroups, CCLI,
Messages, Timers, Stage, Workspace, Props, TestPatterns, Calendar,
KeyMappings, CommunicationDevices).

Built on the MIT-licensed ProPresenter7-Proto schema by greyshirtguy
(v7.16.2). Includes 18 CLI parsers, comprehensive API docs in doc/,
binary-format specs, and a synthetic 369-test PHPUnit suite covering
RTF extraction, translation slides, ZIP64 repair, round-trip fidelity,
and end-to-end generation.
2026-05-03 22:21:01 +02:00

67 lines
2 KiB
PHP
Executable file

#!/usr/bin/env php
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use ProPresenter\Parser\MacrosFileReader;
if ($argc < 2) {
echo "Usage: parse-macros.php <Macros>\n";
exit(1);
}
$filePath = $argv[1];
try {
$library = MacrosFileReader::read($filePath);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
exit(1);
}
$macros = $library->getMacros();
$collections = $library->getCollections();
echo "Macros (" . count($macros) . "):\n";
foreach ($macros as $index => $macro) {
$number = $index + 1;
$name = $macro->getName();
$uuid = $macro->getUuid();
$actionCount = $macro->getActionCount();
$startup = $macro->getTriggerOnStartup() ? ' (startup)' : '';
$memberships = $library->getCollectionsForMacro($macro);
$collectionNames = array_map(fn ($c) => $c->getName(), $memberships);
$collectionSuffix = $collectionNames === [] ? '' : ' [in: ' . implode(', ', $collectionNames) . ']';
$displayName = $name === '' ? '(unnamed)' : $name;
echo " [" . $number . "] " . $displayName . " :: " . $uuid . " (" . $actionCount . " action" . ($actionCount !== 1 ? "s" : "") . ")" . $startup . $collectionSuffix . "\n";
}
echo "\n";
if ($collections === []) {
echo "Collections: (none)\n";
exit(0);
}
echo "Collections (" . count($collections) . "):\n";
foreach ($collections as $index => $collection) {
$number = $index + 1;
$name = $collection->getName();
$uuid = $collection->getUuid();
$resolvedMacros = $library->getMacrosForCollection($collection);
$count = count($resolvedMacros);
$displayName = $name === '' ? '(unnamed)' : $name;
echo " [" . $number . "] " . $displayName . " :: " . $uuid . " (" . $count . " macro" . ($count !== 1 ? "s" : "") . ")\n";
foreach ($resolvedMacros as $macroIndex => $macro) {
$macroNumber = $macroIndex + 1;
$macroName = $macro->getName() === '' ? '(unnamed)' : $macro->getName();
echo " " . $macroNumber . ". " . $macroName . " :: " . $macro->getUuid() . "\n";
}
}