Allow to get version with -V / --version #53

This commit is contained in:
Stéphane Goetz 2018-06-04 22:52:21 +02:00
parent 65f0679d7a
commit 29a8a8d9cc

View File

@ -10,6 +10,26 @@ class Application extends SymfonyApplication
$this->add(new Generate()); $this->add(new Generate());
$this->add(new Serve()); $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'); $this->setDefaultCommand('generate');
} }
} }