Created
January 2, 2015 14:49
-
-
Save memaw/b0755ebffcc5bceb4125 to your computer and use it in GitHub Desktop.
A base for create melody file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<<<CONFIG | |
packages: | |
- "symfony/console: ~2.6" | |
CONFIG; | |
// Documentation de symfony/console : http://symfony.com/fr/doc/current/components/console/introduction.html | |
// Et ses helpers : http://symfony.com/doc/current/components/console/introduction.html#console-helpers | |
use Symfony\Component\Console\Application; | |
use Symfony\Component\Console\Command\Command as SfCommand; | |
use Symfony\Component\Console\Input\InputArgument; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Input\InputOption; | |
use Symfony\Component\Console\Output\OutputInterface; | |
class Command extends SfCommand | |
{ | |
protected function configure() | |
{ | |
$this | |
->setName('my-command') | |
->setDescription('Ma commande') | |
->addArgument('my-required-argument', InputArgument::REQUIRED, 'my-required-argument') | |
->addArgument('my-optional-argument', InputArgument::OPTIONAL, 'my-optional-argument') | |
->addArgument('my-is-array-argument', InputArgument::IS_ARRAY/* | InputArgument::OPTIONAL*/, 'my-is-array-argument') | |
->addOption('my-none-option', null, InputOption::VALUE_NONE, 'my-none-option') | |
->addOption('my-required-option', null, InputOption::VALUE_REQUIRED, 'my-required-option') | |
->addOption('my-optional-option', null, InputOption::VALUE_OPTIONAL, 'my-optional-option') | |
->addOption('my-is-array-option', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'my-is-array-option', array('test1', 'test2')) | |
; | |
} | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$output->writeln(var_export($input->getArgument('my-required-argument'), true)); | |
$output->writeln(var_export($input->getArgument('my-optional-argument'), true)); | |
$output->writeln(var_export($input->getArgument('my-is-array-argument'), true)); | |
$output->writeln(var_export($input->getOption('my-none-option'), true)); | |
$output->writeln(var_export($input->getOption('my-required-option'), true)); | |
$output->writeln(var_export($input->getOption('my-optional-option'), true)); | |
$output->writeln(var_export($input->getOption('my-is-array-option'), true)); | |
} | |
} | |
$application = new Application(); | |
$application->add(new Command()); | |
$application->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment