protected function AnnotatedGreetCommand::execute

master AnnotatedGreetCommand.php protected AnnotatedGreetCommand::execute(InputInterface $input, OutputInterface $output)

Greet someone

@command annotated:greet @arg string $name Who do you want to greet? @option boolean $yell If set, the task will yell in uppercase letters

File

tests/resources/modules/d8/woot/src/Command/AnnotatedGreetCommand.php, line 26

Namespace

Drupal\woot\Command

Class

AnnotatedGreetCommand
This is an annotated version of the example Symfony Console command from the documentation.

Code

protected function execute(InputInterface $input, OutputInterface $output) {
  $name = $input->getArgument('name');
  if ($name) {
    $text = 'Hello ' . $name;
  }
  else {
    $text = 'Hello';
  }

  if ($input->getOption('yell')) {
    $text = strtoupper($text);
  }

  $output->writeln($text);
}