-
Notifications
You must be signed in to change notification settings - Fork 0
/
blade
executable file
·46 lines (36 loc) · 1.29 KB
/
blade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env php
<?php
require __DIR__.'/../vendor/autoload.php';
use NSRosenqvist\Blade\Console\Command;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\HelpCommand;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\EventDispatcher\EventDispatcher;
// Create App
$application = new Application('Blade CLI', '1.1.0');
$dispatcher = new EventDispatcher();
//Add compile command
$compile = new Command\Compile();
$application->add($compile);
// Run help if no arguments are set
$dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) use ($compile) {
$input = $event->getInput();
$output = $event->getOutput();
$command = $event->getCommand();
if ($command->getName() == 'compile') {
$template = $input->getArgument('template');
// Show help message if no arguments are set
if (empty($template)) {
$help = new HelpCommand();
$help->setCommand($compile);
$help->run($input, $output);
$event->disableCommand();
}
}
});
// Single command application
$application->setDefaultCommand($compile->getName(), true);
// Run
$application->setDispatcher($dispatcher);
$application->run();