load config file from different locations, including phar
[bdrem.git] / src / bdrem / UserInterface.php
index 1b8cb56c66d28768b0ff6e33f843ae3b35b2c16e..9fd4d699ccb0757497e5cd99c912337d5dd5654a 100644 (file)
@@ -13,10 +13,14 @@ abstract class UserInterface
             setlocale(LC_TIME, $this->config->locale);
 
             $parser = $this->loadParameters();
-            $this->parseParameters($parser);
+            $res = $this->parseParameters($parser);
+            $this->handleCommands($res);
 
             if (!$this->config->cfgFileExists) {
-                throw new \Exception('No config file found');
+                throw new \Exception(
+                    "No config file found. Looked at the following places:\n"
+                    . '- ' . implode ("\n- ", $this->config->cfgFiles)
+                );
             }
 
             $source = $this->config->loadSource();
@@ -110,6 +114,7 @@ abstract class UserInterface
             $this->config->renderer    = $result->options['renderer'];
             $this->config->stopOnEmpty = $result->options['stopOnEmpty'];
             $this->config->setDate($result->options['date']);
+            return $result;
         } catch (\Exception $exc) {
             $this->preRenderParameterError();
             $parser->displayError($exc->getMessage());
@@ -138,6 +143,10 @@ abstract class UserInterface
         return new $class();
     }
 
+    protected function handleCommands($res)
+    {
+    }
+
     protected function preRenderParameterError()
     {
     }