From c338de3518d7ab6e7f5da310b9de2f5affdc6ca0 Mon Sep 17 00:00:00 2001 From: BlackScorp Date: Tue, 11 Mar 2014 12:17:44 +0100 Subject: [PATCH 1/5] added console support --- composer.json | 5 ++++- lurker.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 lurker.php diff --git a/composer.json b/composer.json index 07750c5..1dbcfea 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "require" : { "php" : ">=5.3.3", + "symfony/console" : "~2.2", "symfony/config" : "~2.2", "symfony/event-dispatcher" : "~2.2" }, @@ -38,5 +39,7 @@ "branch-alias" : { "dev-master" : "1.0.x-dev" } - } + }, + + "bin":["lurker.php"] } diff --git a/lurker.php b/lurker.php new file mode 100755 index 0000000..059f5d9 --- /dev/null +++ b/lurker.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +register('track') + ->addArgument('path') + ->setCode(function(InputInterface $input, OutputInterface $output) { + $config = $input->getArgument('path'); + if ($config && !is_file($config)) + throw new Exception('File not exists'); + + $watcher = require $config; + if(!$watcher instanceof ResourceWatcher) throw new Exception ('Given configurationfile does not retur instance of Lurker/ResrouceWatcher'); + while (true) { + $output->writeln("Start watching..."); + $watcher->start(); + sleep(1); + } + }); + +$console->run(); From 3fd5c5bcc25d7d5f268fc06f225796c946b93eae Mon Sep 17 00:00:00 2001 From: BlackScorp Date: Tue, 11 Mar 2014 12:48:30 +0100 Subject: [PATCH 2/5] suggest the console as optional dependency --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1dbcfea..a58f376 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require" : { "php" : ">=5.3.3", - "symfony/console" : "~2.2", + "symfony/config" : "~2.2", "symfony/event-dispatcher" : "~2.2" }, @@ -32,7 +32,8 @@ }, "suggest" : { - "ext-inotify": ">=0.1.6" + "ext-inotify": ">=0.1.6", + "symfony/console" : "~2.2" }, "extra" : { From d66f6ca3dcc1e1417f3afccc92df6007b5f518ef Mon Sep 17 00:00:00 2001 From: BlackScorp Date: Tue, 11 Mar 2014 12:50:09 +0100 Subject: [PATCH 3/5] formatted composer.json --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a58f376..70e0214 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "require" : { "php" : ">=5.3.3", - "symfony/config" : "~2.2", "symfony/event-dispatcher" : "~2.2" }, @@ -33,7 +32,7 @@ "suggest" : { "ext-inotify": ">=0.1.6", - "symfony/console" : "~2.2" + "symfony/console": "~2.2" }, "extra" : { From 25a3f386a6a6765e9706efec049b13bdc7006b85 Mon Sep 17 00:00:00 2001 From: BlackScorp Date: Tue, 11 Mar 2014 13:15:46 +0100 Subject: [PATCH 4/5] fixed some code standards --- lurker.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lurker.php b/lurker.php index 059f5d9..3be4a1c 100755 --- a/lurker.php +++ b/lurker.php @@ -18,11 +18,15 @@ ->addArgument('path') ->setCode(function(InputInterface $input, OutputInterface $output) { $config = $input->getArgument('path'); - if ($config && !is_file($config)) - throw new Exception('File not exists'); + if ($config && !is_file($config)) { + throw new Exception('File does not exists'); + } $watcher = require $config; - if(!$watcher instanceof ResourceWatcher) throw new Exception ('Given configurationfile does not retur instance of Lurker/ResrouceWatcher'); + if (!$watcher instanceof ResourceWatcher) { + throw new Exception('Given configurationfile does not retur instance of Lurker/ResrouceWatcher'); + } + while (true) { $output->writeln("Start watching..."); $watcher->start(); From 2ea8e62ffbb0cce532ac1beefa2ee981b934f0b0 Mon Sep 17 00:00:00 2001 From: BlackScorp Date: Tue, 11 Mar 2014 13:16:24 +0100 Subject: [PATCH 5/5] fixed typo --- lurker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lurker.php b/lurker.php index 3be4a1c..528718d 100755 --- a/lurker.php +++ b/lurker.php @@ -24,7 +24,7 @@ $watcher = require $config; if (!$watcher instanceof ResourceWatcher) { - throw new Exception('Given configurationfile does not retur instance of Lurker/ResrouceWatcher'); + throw new Exception('Given configuration file does not return instance of Lurker/ResrouceWatcher'); } while (true) {