yamaha-av/bin/console

46 lines
2.1 KiB
Plaintext
Raw Normal View History

2017-11-04 11:33:44 -07:00
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
set_time_limit(0);
/** @var Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], getenv('SILEX_ENV') ?: 'dev');
$debug = getenv('SILEX_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
if($debug){
Debug::enable();
}
$application = new Application('Yamaha AV Console', '0.0.x-dev');
$connection = new \Doctrine\DBAL\Connection([
'driver' => 'pdo_sqlite',
'path' => __DIR__.'/../config/app.db',
'charset' => 'utf8mb4',
'collate' => 'utf8mb4_unicode_ci',
], new Doctrine\DBAL\Driver\PDOSqlite\Driver());
\Doctrine\DBAL\Types\Type::addType('uuid', \Ramsey\Uuid\Doctrine\UuidType::class);
$application->getDefinition()
->addOptions([new \Symfony\Component\Console\Input\InputOption('zone', 'z', \Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Which zone to interact with', 'main')]);
$application->add(new \Sikofitt\Yamaha\AV\Console\Command\MuteCommand());
$application->add(new \Sikofitt\Yamaha\AV\Console\Command\VolumeCommand());
$application->add(new \Sikofitt\Yamaha\AV\Console\Command\StatusCommand($connection));
$application->add(new \Sikofitt\Yamaha\AV\Console\Command\InputCommand());
$application->add(new \Sikofitt\Yamaha\AV\Command\ConfigurationCommand(__DIR__.'/..'));
$application->add(new \Sikofitt\Yamaha\AV\Console\Command\CreateDatabaseCommand($connection));
$application->add(new \Sikofitt\Yamaha\AV\Console\Command\CreateUserCommand($connection));
$application->add(new \Sikofitt\Yamaha\AV\Console\Command\CreateApiTokenCommand(new \Sikofitt\Yamaha\AV\Repository\UserRepository($connection)));
$application->run($input);