addArgument('arg', [ 'required' => true, ]) ->addOption('opt', [ 'short' => 'o', ]); $parser ->addSubcommand('argsAndOptions', [ 'parser' => $argAndOptionParser, ]) ->addSubcommand('bridge') ->addSubcommand('abort_shell'); return $parser; } /** * Bridge of Death question * * @return void */ public function bridge() { $name = $this->in('What is your name'); if ($name !== 'cake') { $this->err('No!'); $this->_stop(Shell::CODE_ERROR); } $color = $this->in('What is your favorite color?'); if ($color !== 'blue') { $this->err('Wrong! Aaaahh'); $this->_stop(Shell::CODE_ERROR); } $this->out('You may pass.'); } /** * A sub command that requires an argument and has an option * * @return void */ public function argsAndOptions() { $this->out('arg: ' . $this->args[0]); $this->out('opt: ' . $this->param('opt')); } /** * @throws \Cake\Console\Exception\StopException */ public function abortShell() { $this->abort('Shell aborted'); } }