Skip to content

Commit

Permalink
Allow to use Processors through the new CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Nov 17, 2016
1 parent 2d451be commit e5c7747
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -26,7 +26,6 @@
},
"autoload": {
"psr-4": {
"Todaymade\\Daux\\Extension\\": "daux/",
"Todaymade\\Daux\\": "libs/"
}
},
Expand Down
17 changes: 1 addition & 16 deletions libs/Console/Serve.php
Expand Up @@ -17,7 +17,6 @@ protected function configure()
->setName('serve')
->setDescription('Serve documentation')


->addOption('configuration', 'c', InputOption::VALUE_REQUIRED, 'Configuration file')
->addOption('source', 's', InputOption::VALUE_REQUIRED, 'Where to take the documentation from')
->addOption('processor', 'p', InputOption::VALUE_REQUIRED, 'Manipulations on the tree')
Expand All @@ -44,9 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
putenv('DAUX_SOURCE=' . $daux->getParams()->getDocumentationDirectory());
putenv('DAUX_THEME=' . $daux->getParams()->getThemesPath());
putenv('DAUX_CONFIGURATION=' . $daux->getParams()->getConfigurationOverrideFile());

//TODO :: support processor
//putenv('DAUX_PROCESSOR=' . $daux->getParams()->getProcessorFile());
putenv('DAUX_EXTENSION=' . DAUX_EXTENSION);

$base = ProcessUtils::escapeArgument(__DIR__ . '/../../');
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
Expand All @@ -63,16 +60,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
passthru("{$binary} -S {$host}:{$port} {$base}/index.php");
}
}

protected function prepareProcessor(Daux $daux, InputInterface $input, OutputInterface $output, $width)
{
if ($input->getOption('processor')) {
$daux->getParams()['processor'] = $input->getOption('processor');
}

$class = $daux->getProcessorClass();
if (!empty($class)) {
$daux->setProcessor(new $class($daux, $output, $width));
}
}
}
46 changes: 33 additions & 13 deletions libs/bootstrap.php
@@ -1,20 +1,40 @@
<?php

// Loaded as a dependency
if (file_exists(__DIR__ . '/../../../autoload.php')) {
return require_once __DIR__ . '/../../../autoload.php';
}
function loadApp() {
// Loaded as a dependency
if (file_exists(__DIR__ . '/../../../autoload.php')) {
return require_once __DIR__ . '/../../../autoload.php';
}

// Loaded in the project itself
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
return require_once __DIR__ . '/../vendor/autoload.php';
}
// Loaded in the project itself
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
return require_once __DIR__ . '/../vendor/autoload.php';
}

// Loaded in the project itself, when vendor isn't installed
if (file_exists(__DIR__ . '/../daux.phar')) {
define('PHAR_DIR', __DIR__ . '/..');
// Loaded in the project itself, when vendor isn't installed
if (file_exists(__DIR__ . '/../daux.phar')) {
define('PHAR_DIR', __DIR__ . '/..');

return require_once 'phar://' . __DIR__ . '/../daux.phar/vendor/autoload.php';
return require_once 'phar://' . __DIR__ . '/../daux.phar/vendor/autoload.php';
}

throw new Exception('Impossible to load Daux, missing vendor/ or daux.phar');
}

throw new Exception('Impossible to load Daux, missing vendor/ or daux.phar');
$loader = loadApp();

if ($loader) {
$ext = __DIR__ . '/../daux';
if (is_dir(getcwd() . "/daux")) {
$ext = getcwd() . "/daux";
}

$env = getenv('DAUX_EXTENSION');
if ($env && is_dir($env)) {
$ext = $env;
}

define('DAUX_EXTENSION', $ext);

$loader->setPsr4("Todaymade\\Daux\\Extension\\", $ext);
}

0 comments on commit e5c7747

Please sign in to comment.