debug option for mail renderer
[bdrem.git] / src / bdrem / UserInterface.php
index ef18493d99e6c3fa8894a454763419eddc1aec92..8a25bf4967a9438243404bfd7574ef966412ce4c 100644 (file)
@@ -45,6 +45,9 @@ abstract class UserInterface
             $res = $this->parseParameters($parser);
 
             $this->config->load();
+            setlocale(LC_TIME, $this->config->locale);
+            $this->handleCommands($res);
+
             if (!$this->config->cfgFileExists) {
                 throw new \Exception(
                     "No config file found. Looked at the following places:\n"
@@ -52,9 +55,6 @@ abstract class UserInterface
                 );
             }
 
-            setlocale(LC_TIME, $this->config->locale);
-            $this->handleCommands($res);
-
             $source = $this->config->loadSource();
             $arEvents = $source->getEvents(
                 $this->config->date,
@@ -149,6 +149,14 @@ abstract class UserInterface
                 'action'      => 'StoreString'
             )
         );
+        $parser->addOption(
+            'debug',
+            array(
+                'long_name'   => '--debug',
+                'description' => 'Development helper (mail)',
+                'action'      => 'StoreTrue'
+            )
+        );
 
         return $parser;
     }
@@ -171,6 +179,7 @@ abstract class UserInterface
 
             $this->config->daysNext    = $result->options['daysNext'];
             $this->config->daysPrev    = $result->options['daysPrev'];
+            $this->config->debug       = $result->options['debug'];
             $this->config->renderer    = $result->options['renderer'];
             $this->config->stopOnEmpty = $result->options['stopOnEmpty'];
             $this->config->setDate($result->options['date']);