Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Migrate to Symfony Finder Component
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrzejchalubek committed Jan 18, 2017
1 parent e91a6e0 commit e161323
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 29 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"require": {
"php": ">=5.6"
},
"require-dev": {
"symfony/console": "~2.3|~3.0"
"suggest": {
"symfony/console": "[Gin CLI] Required for the proper operation of Console component",
"symfony/finder": "[Gin CLI] Needed for `gin tonik:shake` command"
},
"autoload": {
"psr-4": {
Expand Down
284 changes: 281 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions gin
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env php
<?php

use Symfony\Component\Console\Exception\RuntimeException;

if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
require $composer;

return new Tonik\Gin\Foundation\Console\CLI(__DIR__);
}

throw new RuntimeException("Please, install composer dependences before running CLI.");
19 changes: 16 additions & 3 deletions src/Gin/Foundation/Console/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tonik\Gin\Foundation\Console;

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;

class CLI
{
Expand Down Expand Up @@ -37,10 +38,12 @@ class CLI
/**
* Construct CLI.
*/
function __construct()
function __construct($dir)
{
$this->app = new Application($this->banner);

$this->dir = $dir;

$this->bootstrap();
}

Expand All @@ -63,8 +66,18 @@ protected function bootstrap()
*/
protected function addCommands(array $commands)
{
foreach ($commands as $command) {
$this->app->add(new $command);
foreach ($commands as $name) {
$command = new $name;

$command->addOption(
'directory',
'dir',
InputOption::VALUE_REQUIRED,
'Root directory path of theme.',
$this->dir
);

$this->app->add($command);
}
}
}
Loading

0 comments on commit e161323

Please sign in to comment.