-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-labels.php
More file actions
executable file
·47 lines (37 loc) · 1.01 KB
/
Copy pathparse-labels.php
File metadata and controls
executable file
·47 lines (37 loc) · 1.01 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
#!/usr/bin/env php
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use ProPresenter\Parser\LabelsFileReader;
if ($argc < 2) {
echo "Usage: parse-labels.php <Labels>\n";
exit(1);
}
$filePath = $argv[1];
try {
$library = LabelsFileReader::read($filePath);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
exit(1);
}
$labels = $library->getLabels();
echo "Labels (" . count($labels) . "):\n";
foreach ($labels as $index => $label) {
$number = $index + 1;
$name = $label->getName();
$displayName = $name === '' ? '(unnamed)' : $name;
if ($label->hasColor()) {
$color = $label->getColor();
$colorPart = sprintf(
'%s rgba(%.3f, %.3f, %.3f, %.3f)',
$label->getColorHex(),
$color['r'],
$color['g'],
$color['b'],
$color['a'],
);
} else {
$colorPart = '(no color)';
}
echo sprintf(" [%d] %s :: %s\n", $number, $displayName, $colorPart);
}