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 if ($this->config->replayFile !== null) {
28 $sourceClass = 'callnotifier\Source_File';
30 $sourceClass = 'callnotifier\Source_Remote';
32 $source = new $sourceClass($this->config, $handler);
36 public function setupCli()
38 $p = new \Console_CommandLine();
39 $p->description = 'Notifies about incoming calls on an Auerswald COMpact 3000';
40 $p->version = '0.0.1';
46 'long_name' => '--host',
47 'description' => 'IP of COMpact 3000',
49 'action' => 'StoreString'
56 'long_name' => '--dump',
57 'description' => 'dump messages into file for later replay',
58 'help_name' => 'FILE',
59 'action' => 'StoreString'
65 'long_name' => '--replay',
66 'description' => "Replay messages from file instead from network",
67 'help_name' => 'FILE',
68 'action' => 'StoreString'
72 $this->cliParser = $p;
75 protected function fillConfig($config, $result)
77 $config->setIfNotEmpty('host', $result->options['host']);
78 $config->setIfNotEmpty('dumpFile', $result->options['dumpFile']);
79 $config->setIfNotEmpty('replayFile', $result->options['replayFile']);