protected function interact(InputInterface $input, OutputInterface $output) { $output->writeln($this->app['app.signature']); $title = $input->getArgument('title'); if (null !== $title && '' !== $title) { return; } $output->writeln(array('', ' Welcome to the <comment>easybook</comment> interactive book generator', '')); $dialog = $this->getHelperSet()->get('dialog'); // check `title` argument $title = $input->getArgument('title') ?: $dialog->askAndValidate($output, "\n Please, type the <info>title</info> of the book" . ' (e.g. <comment>The Origin of Species</comment>)' . "\n > ", function ($title) { return Validator::validateNonEmptyString('title', $title); }); $input->setArgument('title', $title); }
protected function interact(InputInterface $input, OutputInterface $output) { $output->writeln($this->app['app.signature']); $slug = $input->getArgument('slug'); $edition = $input->getArgument('edition'); if (!empty($slug) && !empty($edition)) { return; } $output->writeln(array('', ' Welcome to the <comment>easybook</comment> interactive book customizer', '')); $dialog = $this->getHelperSet()->get('dialog'); // check 'slug' argument $slug = $input->getArgument('slug') ?: $dialog->askAndValidate($output, array(" Please, type the <info>slug</info> of the book (e.g. <comment>the-origin-of-species</comment>)\n", ' > '), function ($slug) { return Validator::validateBookSlug($slug); }); $input->setArgument('slug', $slug); // check 'edition' argument $edition = $input->getArgument('edition') ?: $dialog->askAndValidate($output, array(" Please, type the name of the <info>edition</info> to be customized (e.g. <comment>web</comment>)\n", ' > '), function ($edition) { return Validator::validateEditionSlug($edition); }); $input->setArgument('edition', $edition); }