pdf-finder/bin/pdf-finder.php

27 lines
726 B
PHP
Raw Permalink Normal View History

2021-03-23 21:58:40 +01:00
#!/usr/bin/env php
<?php
use IO\ExceptionHandler;
use IO\Input\FinderArguments;
2021-04-08 15:36:57 +02:00
use IO\Output\DocumentListing;
2021-03-23 21:58:40 +01:00
use PDF\Document;
require_once __DIR__ . '/../vendor/autoload.php';
ExceptionHandler::registerCallback();
$arguments = FinderArguments::createFromGlobals();
$directory = $arguments->getDirectory();
$filters = $arguments->getFilters();
printf('Scanning "%s"...%s', $directory, PHP_EOL);
$locator = new RecursiveDocumentLocator();
$documents = $locator->findDocuments($directory);
foreach ($filters as $filter) {
printf('Applying filter { %s }...%s', $filter, PHP_EOL);
$documents = $documents->filter(fn(Document $document) => $filter->allows($document));
}
2021-04-08 15:36:57 +02:00
DocumentListing::of($documents)->render();