2 namespace callnotifier;
10 public function __construct()
17 $this->config = new Config();
19 $result = $this->cliParser->parse();
20 } catch (\Exception $exc) {
21 $this->cliParser->displayError($exc->getMessage());
24 $this->fillConfig($this->config, $result);
26 $handler = new MessageHandler($this->config);
27 $handler->addLogger(new Logger_Echo(), '*');
29 if ($this->config->replayFile !== null) {
30 $sourceClass = 'callnotifier\Source_File';
32 $sourceClass = 'callnotifier\Source_Remote';
34 $source = new $sourceClass($this->config, $handler);
38 public function setupCli()
40 $p = new \Console_CommandLine();
41 $p->description = 'Notifies about incoming calls on an Auerswald COMpact 3000';
42 $p->version = '0.0.1';
48 'long_name' => '--host',
49 'description' => 'IP of COMpact 3000',
51 'action' => 'StoreString'
58 'long_name' => '--dump',
59 'description' => 'dump messages into file for later replay',
60 'help_name' => 'FILE',
61 'action' => 'StoreString'
67 'long_name' => '--replay',
68 'description' => "Replay messages from file instead from network",
69 'help_name' => 'FILE',
70 'action' => 'StoreString'
74 $this->cliParser = $p;
77 protected function fillConfig($config, $result)
79 $config->setIfNotEmpty('host', $result->options['host']);
80 $config->setIfNotEmpty('dumpFile', $result->options['dumpFile']);
81 $config->setIfNotEmpty('replayFile', $result->options['replayFile']);