Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new ConsoleIO($input, $output);
     $this->welcomeMessage($io);
     $title = $io->askAndValidate('Post title', function ($answer) {
         return Validators::validatePostTitle($answer);
     }, false, $input->getOption('title'));
     $input->setOption('title', $title);
     $layout = $io->ask('Post layout', $input->getOption('layout'));
     $input->setOption('layout', $layout);
     $defaultDate = $input->getOption('date');
     if (empty($defaultDate) === true) {
         $defaultDate = $this->getDateFormated();
     }
     $date = $io->ask('Post date', $defaultDate);
     $input->setOption('date', $date);
     if ($io->askConfirmation('Do you want to use tags?', empty($input->getOption('tags')) === false)) {
         $tags = $io->ask('Comma separated list of post tags', $input->getOption('tags'));
         $input->setOption('tags', $tags);
     }
     if ($io->askConfirmation('Do you want to use categories?', empty($input->getOption('categories')) === false)) {
         $categories = $io->ask('Comma separated list of post categories', $input->getOption('categories'));
         $input->setOption('categories', $categories);
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     $this->welcomeMessage($io);
     $title = $input->getOption('title');
     $question = new Question('Post title: ', $title);
     $question->setMaxAttempts(null);
     $question->setValidator(function ($answer) {
         return Validators::validatePostTitle($answer);
     });
     $title = $helper->ask($input, $output, $question);
     $input->setOption('title', $title);
     $layout = $input->getOption('layout');
     $question = new Question('Post layout: ', $layout);
     $layout = $helper->ask($input, $output, $question);
     $input->setOption('layout', $layout);
     $date = $input->getOption('date') ?: $this->getDateFormated();
     $question = new Question("Post date ({$date}): ", $date);
     $date = $helper->ask($input, $output, $question);
     $input->setOption('date', $date);
     $tags = $input->getOption('tags') ?: '';
     $question = new Question('Comma separated list of post tags: ', $tags);
     $tags = $helper->ask($input, $output, $question);
     $input->setOption('tags', $tags);
     $categories = $input->getOption('categories') ?: '';
     $question = new Question('Comma separated list of post categories: ', $categories);
     $categories = $helper->ask($input, $output, $question);
     $input->setOption('categories', $categories);
 }
Exemplo n.º 3
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testValidateEmptyEmail()
 {
     Validators::validateEmail('');
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new ConsoleIO($input, $output);
     $this->welcomeMessage($io);
     $name = $io->askAndValidate('Plugin name (follow the pattern <comment>"vendor-name/plugin-name"</comment>)', function ($answer) {
         return Validators::validatePluginName($answer);
     }, false, $input->getOption('name'));
     $input->setOption('name', $name);
     if ($io->askConfirmation('Is it a command plugin?', empty($input->getOption('name')) === false)) {
         $commandName = $io->askAndValidate('Name of the command', function ($answer) {
             return Validators::validateCommandName($answer);
         }, false, $input->getOption('command-name'));
         $input->setOption('command-name', $commandName);
         $commandDescription = $io->ask('Description for the command', $input->getOption('command-description'));
         $input->setOption('command-description', $commandDescription);
         $commandHelp = $io->ask('Help for the command', $input->getOption('command-help'));
         $input->setOption('command-help', $commandHelp);
     }
     $author = $io->ask('Plugin author', $input->getOption('author'));
     $input->setOption('author', $author);
     $email = $io->askAndValidate('Email author', function ($answer) {
         return Validators::validateEmail($answer);
     }, false, $input->getOption('email'));
     $input->setOption('email', $email);
     $description = $io->ask('Plugin description', $input->getOption('description'));
     $input->setOption('description', $description);
     $this->licenseMessage($io);
     $defaultLicense = $input->getOption('license');
     if (is_null($defaultLicense) === true) {
         $defaultLicense = 'MIT';
     }
     $license = $io->ask('Plugin license', $defaultLicense);
     $input->setOption('license', $license);
 }
Exemplo n.º 5
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testValidateInvalidEmail()
 {
     Validators::validateEmail('@example.com');
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $io = new ConsoleIO($input, $output, $this->getHelperSet());
     $this->welcomeMessage($io);
     $name = $input->getOption('name');
     $question = new Question('Plugin name <info>(follow the pattern</info> <comment>"vendor-name/plugin-name"</comment><info>)</info>: ', $name);
     $question->setMaxAttempts(null);
     $question->setValidator(function ($answer) {
         return Validators::validatePluginName($answer);
     });
     $name = $helper->ask($input, $output, $question);
     $input->setOption('name', $name);
     $question = new ConfirmationQuestion('Is it a command plugin?[<comment>n</comment>]: ', false);
     $isCommandPlugin = $helper->ask($input, $output, $question);
     if ($isCommandPlugin === true) {
         $commandName = $input->getOption('command-name');
         $question = new Question('Name of the command: ', $commandName);
         $question->setMaxAttempts(null);
         $question->setValidator(function ($answer) {
             return Validators::validateCommandName($answer);
         });
         $commandName = $helper->ask($input, $output, $question);
         $input->setOption('command-name', $commandName);
         $commandDescription = $input->getOption('command-description');
         $question = new Question('Description for the command: ', $commandDescription);
         $commandDescription = $helper->ask($input, $output, $question);
         $input->setOption('command-description', $commandDescription);
         $commandHelp = $input->getOption('command-help');
         $question = new Question('Help for the command: ', $commandHelp);
         $commandHelp = $helper->ask($input, $output, $question);
         $input->setOption('command-help', $commandHelp);
     }
     $author = $input->getOption('author');
     $question = new Question('Plugin author: ', $author);
     $author = $helper->ask($input, $output, $question);
     $input->setOption('author', $author);
     $email = $input->getOption('email');
     $question = new Question('Email author: ', $email);
     $question->setValidator(function ($answer) {
         return Validators::validateEmail($answer, true);
     });
     $email = $helper->ask($input, $output, $question);
     $input->setOption('email', $email);
     $description = $input->getOption('description');
     $question = new Question('Plugin description: ', $description);
     $description = $helper->ask($input, $output, $question);
     $input->setOption('description', $description);
     $this->licenseMessage($io);
     $license = $input->getOption('license');
     $question = new Question('Plugin license [<comment>MIT</comment>]: ', $license);
     $license = $helper->ask($input, $output, $question);
     $input->setOption('license', $license);
 }