-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added console support #10
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
// installed via composer? | ||
if (file_exists($a = __DIR__ . '/../../autoload.php')) { | ||
require_once $a; | ||
} else { | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
} | ||
|
||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Lurker\ResourceWatcher; | ||
|
||
$console = new Application(); | ||
|
||
$console->register('track') | ||
->addArgument('path') | ||
->setCode(function(InputInterface $input, OutputInterface $output) { | ||
$config = $input->getArgument('path'); | ||
if ($config && !is_file($config)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gah, no usage of curly braces is a bad practice |
||
throw new Exception('File not exists'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does not |
||
|
||
$watcher = require $config; | ||
if(!$watcher instanceof ResourceWatcher) throw new Exception ('Given configurationfile does not retur instance of Lurker/ResrouceWatcher'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no cs space after if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no parenethesis 😿 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are at least 3 typos on this line |
||
while (true) { | ||
$output->writeln("Start watching..."); | ||
$watcher->start(); | ||
sleep(1); | ||
} | ||
}); | ||
|
||
$console->run(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why .php? since you are adding the shebang below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
took this as example from fabpot/Sami i dont really know how to create console files