diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6df3d04 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +tags +vendor +composer.lock +*.swp diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..40342d2 --- /dev/null +++ b/bin/console @@ -0,0 +1,13 @@ +#!/usr/bin/env php +chdir(__DIR__.'/../'); +$app->addCommandsPath('src/Deblan/Command/', 'Deblan\\Command'); +$app->loadCommands(); +$app->run(); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..6970a3d --- /dev/null +++ b/composer.json @@ -0,0 +1,12 @@ +{ + "autoload": { + "psr-0": { + "": "src/" + } + }, + "require": { + "symfony/filesystem": "^2.7", + "symfony/finder": "^2.7", + "symfony/console": "^2.7" + } +} diff --git a/src/Deblan/.Application.php.swp b/src/Deblan/.Application.php.swp new file mode 100644 index 0000000..481386d Binary files /dev/null and b/src/Deblan/.Application.php.swp differ diff --git a/src/Deblan/Application.php b/src/Deblan/Application.php new file mode 100644 index 0000000..54e2061 --- /dev/null +++ b/src/Deblan/Application.php @@ -0,0 +1,58 @@ +commandsPaths[$path] = trim($namespace, '\\'); + + return $this; + } + + public function chdir($directory) + { + chdir($directory); + + return $this; + } + + public function loadCommands() + { + foreach ($this->commandsPaths as $path => $namespace) { + $finder = new Finder(); + $finder->name('*Command.php')->in($path); + + foreach ($finder as $file) { + $className = $namespace.'\\'.str_replace('.php', '', $file->getFilename()); + + try { + $reflexion = new ReflectionClass($className); + + if ($reflexion->isInstantiable()) { + $command = new $className(); + + $this->addCommands(array( + $command, + )); + } + } catch (ReflectionException $e) { + + } + } + } + + return $this; + } +} +