lucky = $lucky; parent::__construct($name); } /** * {@inheritdoc} * * Nothing in parent, so don't call it. */ protected function configure() { $this->setName('app:lucky') ->setDescription('Draws a lucky number') ->setHelp('Draws a pseudo-random number, or returns the one you pass') ->addOption(static::O_DELEGATE, 'd', InputOption::VALUE_NONE, 'Delegate to demo bundle command'); } protected function execute(InputInterface $input, OutputInterface $output) { // Delegate to bundle commande. if ($input->getOption(static::O_DELEGATE)) { $bundleCommand = $this->getApplication()->find(DemoCommand::NAME); $arguments = []; $commandInput = new ArrayInput($arguments); $commandOutput = new NullOutput(); // Pass no options/arguments, mask commmand output. $value = $bundleCommand->run($commandInput, $commandOutput); } // Perform value selection directly. else { $value = $this->lucky->number(); } $output->writeln($value); } }