X-Git-Url: https://git.cweiske.de/bdrem.git/blobdiff_plain/e946d300f1c3c0d5c5805cd73c035fde0a4d0de2..83afda94b7d5fc2be341712e2661f6095f608e0d:/src/bdrem/UserInterface.php diff --git a/src/bdrem/UserInterface.php b/src/bdrem/UserInterface.php index 7e6bf9a..4e27d5d 100644 --- a/src/bdrem/UserInterface.php +++ b/src/bdrem/UserInterface.php @@ -11,11 +11,16 @@ abstract class UserInterface $this->config = new Config(); $this->config->load(); setlocale(LC_TIME, $this->config->locale); - $source = $this->config->loadSource(); $parser = $this->loadParameters(); - $this->parseParameters($parser); + $res = $this->parseParameters($parser); + $this->handleCommands($res); + + if (!$this->config->cfgFileExists) { + throw new \Exception('No config file found'); + } + $source = $this->config->loadSource(); $arEvents = $source->getEvents( $this->config->date, $this->config->daysPrev, $this->config->daysNext @@ -24,7 +29,7 @@ abstract class UserInterface $this->render($arEvents); } catch (\Exception $e) { $this->preRenderParameterError(); - echo 'Exception: ' . $e->getCode() . ' ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getCode() . ' - ' . $e->getMessage() . "\n"; exit(1); } } @@ -93,15 +98,6 @@ abstract class UserInterface 'action' => 'StoreString' ) ); - $parser->addOption( - 'quiet', - array( - 'short_name' => '-q', - 'long_name' => '--quiet', - 'description' => "Don't print status messages to stdout", - 'action' => 'StoreTrue' - ) - ); return $parser; } @@ -113,9 +109,9 @@ abstract class UserInterface $this->config->daysNext = $result->options['daysNext']; $this->config->daysPrev = $result->options['daysPrev']; $this->config->renderer = $result->options['renderer']; - $this->config->quiet = $result->options['quiet']; $this->config->stopOnEmpty = $result->options['stopOnEmpty']; $this->config->setDate($result->options['date']); + return $result; } catch (\Exception $exc) { $this->preRenderParameterError(); $parser->displayError($exc->getMessage()); @@ -144,6 +140,10 @@ abstract class UserInterface return new $class(); } + protected function handleCommands($res) + { + } + protected function preRenderParameterError() { }