Skip to content

Instantly share code, notes, and snippets.

@ngyuki
Created July 2, 2014 16:29
Show Gist options
  • Save ngyuki/82e7a553e2d78237bc87 to your computer and use it in GitHub Desktop.
Save ngyuki/82e7a553e2d78237bc87 to your computer and use it in GitHub Desktop.
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
$commands = [];
$commands[] = (new Command('hello'))
->setDescription("Hello")
->addOption("name", "N", InputOption::VALUE_OPTIONAL, "Name", "unknown")
->setCode(function (InputInterface $input, OutputInterface $output) {
$name = $input->getOption('name');
$output->writeln("hello <info>$name</info>");
})
;
$app = new Application();
$app->addCommands($commands);
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment