diff --git a/libs/Console/DauxCommand.php b/libs/Console/DauxCommand.php
index fd16eb6..dafa5ea 100644
--- a/libs/Console/DauxCommand.php
+++ b/libs/Console/DauxCommand.php
@@ -3,6 +3,7 @@
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
use Todaymade\Daux\Daux;
class DauxCommand extends SymfonyCommand
@@ -50,9 +51,9 @@ class DauxCommand extends SymfonyCommand
}
}
- protected function prepareDaux(InputInterface $input)
+ protected function prepareDaux(InputInterface $input, OutputInterface $output)
{
- $daux = new Daux(Daux::STATIC_MODE);
+ $daux = new Daux(Daux::STATIC_MODE, $output);
// Set the format if requested
if ($input->hasOption('format') && $input->getOption('format')) {
diff --git a/libs/Console/Generate.php b/libs/Console/Generate.php
index dac264d..158ef9d 100755
--- a/libs/Console/Generate.php
+++ b/libs/Console/Generate.php
@@ -42,7 +42,7 @@ class Generate extends DauxCommand
$input = new ArgvInput($argv, $this->getDefinition());
}
- $daux = $this->prepareDaux($input);
+ $daux = $this->prepareDaux($input, $output);
$width = (new Terminal)->getWidth();
diff --git a/libs/Console/RunAction.php b/libs/Console/RunAction.php
index e2fbf9a..a3a62b4 100644
--- a/libs/Console/RunAction.php
+++ b/libs/Console/RunAction.php
@@ -1,6 +1,7 @@
write($title);
+ $verbose = Daux::getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
+
+ Daux::write($title, $verbose);
// 8 is the length of the label + 2 let it breathe
$padding = $width - $this->getLength($title) - 10;
+
try {
- $response = $closure(function ($content) use ($output, &$padding) {
+ $response = $closure(function ($content) use (&$padding) {
$padding -= $this->getLength($content);
- $output->write($content);
+ Daux::write($content, $verbose);
});
} catch (\Exception $e) {
- $output->writeln(str_pad(' ', $padding) . '[ FAIL ]');
+ $this->status($padding, '[ FAIL ]');
throw $e;
}
- $output->writeln(str_pad(' ', $padding) . '[ OK ]');
+ $this->status($padding, '[ OK ]');
return $response;
}
+
+ protected function status($padding, $content)
+ {
+ $verbose = Daux::getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
+ $padding = $verbose ? '' : str_pad(' ', $padding);
+ Daux::writeln($padding . $content);
+ }
}
diff --git a/libs/Console/Serve.php b/libs/Console/Serve.php
index 1fb7deb..8c7891b 100755
--- a/libs/Console/Serve.php
+++ b/libs/Console/Serve.php
@@ -30,7 +30,7 @@ class Serve extends DauxCommand
$host = $input->getOption('host');
$port = $input->getOption('port');
- $daux = $this->prepareDaux($input);
+ $daux = $this->prepareDaux($input, $output);
// Daux can only serve HTML
$daux->getParams()->setFormat('html');
diff --git a/libs/Daux.php b/libs/Daux.php
index c0361df..639f8cc 100644
--- a/libs/Daux.php
+++ b/libs/Daux.php
@@ -1,6 +1,7 @@
mode = $mode;
$this->local_base = dirname(__DIR__);
@@ -236,7 +240,7 @@ class Daux
public function getProcessor()
{
if (!$this->processor) {
- $this->processor = new Processor($this, new NullOutput(), 0);
+ $this->processor = new Processor($this, Daux::getOutput(), 0);
}
return $this->processor;
@@ -347,4 +351,37 @@ class Daux
return $this->validExtensions = $this->getContentTypeHandler()->getContentExtensions();
}
+
+ public static function getOutput() {
+ if (!Daux::$output) {
+ Daux:$output = new NullOutput();
+ }
+
+ return Daux::$output;
+ }
+
+ /**
+ * Writes a message to the output.
+ *
+ * @param string|array $messages The message as an array of lines or a single string
+ * @param bool $newline Whether to add a newline
+ * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
+ */
+ public static function write($messages, $newline = false, $options = 0) {
+ Daux::$output->write($messages, $newline, $options);
+ }
+
+ /**
+ * Writes a message to the output and adds a newline at the end.
+ *
+ * @param string|array $messages The message as an array of lines of a single string
+ * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
+ */
+ public static function writeln($messages, $options = 0) {
+ Daux::write($messages, true, $options);
+ }
+
+ public static function getVerbosity() {
+ return Daux::getOutput()->getVerbosity();
+ }
}
diff --git a/libs/Format/Confluence/Generator.php b/libs/Format/Confluence/Generator.php
index 037fd61..0c70c23 100644
--- a/libs/Format/Confluence/Generator.php
+++ b/libs/Format/Confluence/Generator.php
@@ -79,7 +79,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
$tree = $this->runAction(
'Generating Tree ...',
- $output,
$width,
function() use ($params) {
$tree = $this->generateRecursive($this->daux->tree, $params);
diff --git a/libs/Format/Confluence/Publisher.php b/libs/Format/Confluence/Publisher.php
index c4811d7..94a4832 100644
--- a/libs/Format/Confluence/Publisher.php
+++ b/libs/Format/Confluence/Publisher.php
@@ -41,7 +41,7 @@ class Publisher
public function run($title, $closure)
{
try {
- return $this->runAction($title, $this->output, $this->width, $closure);
+ return $this->runAction($title, $this->width, $closure);
} catch (BadResponseException $e) {
$this->output->writeLn('' . $e->getMessage() . '>');
}
diff --git a/libs/Format/HTML/Generator.php b/libs/Format/HTML/Generator.php
index efa9395..64fc3d0 100755
--- a/libs/Format/HTML/Generator.php
+++ b/libs/Format/HTML/Generator.php
@@ -80,7 +80,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
$this->runAction(
'Copying Static assets ...',
- $output,
$width,
function() use ($destination, $params) {
$this->ensureEmptyDestination($destination);
@@ -194,7 +193,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
} else {
$this->runAction(
'- ' . $node->getUrl(),
- $output,
$width,
function() use ($node, $output_dir, $key, $params, $index_pages) {
if ($node instanceof Raw) {
diff --git a/libs/Format/HTML/Template.php b/libs/Format/HTML/Template.php
index 37239d1..691fbb8 100644
--- a/libs/Format/HTML/Template.php
+++ b/libs/Format/HTML/Template.php
@@ -1,6 +1,7 @@
engine->addFolder('theme', $theme, true);
+ Daux::writeln("Starting Template engine with basedir '$base' and theme folder '$theme'.", OutputInterface::VERBOSITY_VERBOSE);
+
$this->registerFunctions($this->engine);
return $this->engine;
@@ -65,6 +68,8 @@ class Template
'tree' => $data['params']['tree'],
]);
+ Daux::writeln("Rendering template '$name'", OutputInterface::VERBOSITY_VERBOSE);
+
return $engine->render($name, $data);
}
diff --git a/libs/Format/HTMLFile/Generator.php b/libs/Format/HTMLFile/Generator.php
index 275769e..29d3bff 100644
--- a/libs/Format/HTMLFile/Generator.php
+++ b/libs/Format/HTMLFile/Generator.php
@@ -74,7 +74,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
return $pdf;
}
-
/**
* {@inheritdoc}
*/
@@ -90,7 +89,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
while ($current) {
$this->runAction(
'Generating ' . $current->getTitle(),
- $output,
$width,
function () use ($book, $current, $params) {
$contentType = $this->daux->getContentTypeHandler()->getType($current);
diff --git a/libs/Server/Server.php b/libs/Server/Server.php
index cd9758a..6695686 100755
--- a/libs/Server/Server.php
+++ b/libs/Server/Server.php
@@ -31,12 +31,14 @@ class Server
*/
public static function serve()
{
- $daux = new Daux(Daux::LIVE_MODE);
+ $output = new NullOutput();
+
+ $daux = new Daux(Daux::LIVE_MODE, $output);
$daux->initializeConfiguration();
$class = $daux->getProcessorClass();
if (!empty($class)) {
- $daux->setProcessor(new $class($daux, new NullOutput(), 0));
+ $daux->setProcessor(new $class($daux, $output, 0));
}
// Set this critical configuration