daux.io/libs/Console/Application.php
2018-06-04 22:52:21 +02:00

36 lignes
1.0 KiB
PHP

<?php namespace Todaymade\Daux\Console;
use Symfony\Component\Console\Application as SymfonyApplication;
class Application extends SymfonyApplication
{
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
{
parent::__construct($name, $version);
$this->add(new Generate());
$this->add(new Serve());
$app_name = "daux/daux.io";
$up = '..' . DIRECTORY_SEPARATOR;
$composer = __DIR__ . DIRECTORY_SEPARATOR . $up . $up . $up . $up . $up . 'composer.lock';
$version = "unknown";
if (file_exists($composer)) {
$app = json_decode(file_get_contents($composer));
$packages = $app->packages;
foreach ($packages as $package) {
if ($package->name == $app_name) {
$version = $package->version;
}
}
}
$this->setVersion($version);
$this->setName($app_name);
$this->setDefaultCommand('generate');
}
}