Version 1
[yaffs-website] / vendor / drush / drush / tests / resources / modules / d8 / woot / src / Commands / AnnotatedGreetCommand.php
1 <?php
2 namespace Drupal\woot\Commands;
3
4 use Consolidation\AnnotatedCommand\AnnotatedCommand;
5 use Symfony\Component\Console\Command\Command;
6 use Symfony\Component\Console\Input\InputArgument;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Input\InputOption;
9 use Symfony\Component\Console\Output\OutputInterface;
10
11 /**
12  * This is an annotated version of the example Symfony Console command
13  * from the documentation.
14  *
15  * See: http://symfony.com/doc/2.7/components/console/introduction.html#creating-a-basic-command
16  */
17 class AnnotatedGreetCommand extends AnnotatedCommand
18 {
19     /**
20      * Greet someone
21      *
22      * @command annotated:greet
23      * @arg string $name Who do you want to greet?
24      * @option boolean $yell If set, the task will yell in uppercase letters
25      */
26     protected function execute(InputInterface $input, OutputInterface $output)
27     {
28         $name = $input->getArgument('name');
29         if ($name) {
30             $text = 'Hello '.$name;
31         } else {
32             $text = 'Hello';
33         }
34
35         if ($input->getOption('yell')) {
36             $text = strtoupper($text);
37         }
38
39         $output->writeln($text);
40     }
41 }