-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-macros.php
More file actions
executable file
·66 lines (51 loc) · 2.04 KB
/
Copy pathparse-macros.php
File metadata and controls
executable file
·66 lines (51 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/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";
}
}