use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
use Drupal\Console\Generator\HelpGenerator;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Command\Shared\ConfirmationTrait;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
use Drupal\Console\Extension\Manager;
-use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Utils\Site;
use Drupal\Console\Core\Utils\ChainQueue;
+use Drupal\Console\Utils\Validator;
class HelpCommand extends Command
{
- use CommandTrait;
use ModuleTrait;
use ConfirmationTrait;
/**
- * @var HelpGenerator
-*/
+ * @var HelpGenerator
+ */
protected $generator;
/**
protected $site;
/**
- * @var Manager
-*/
+ * @var Manager
+ */
protected $extensionManager;
/**
*/
protected $chainQueue;
+ /**
+ * @var Validator
+ */
+ protected $validator;
+
/**
* HelpCommand constructor.
HelpGenerator $generator,
Site $site,
Manager $extensionManager,
- ChainQueue $chainQueue
+ ChainQueue $chainQueue,
+ Validator $validator
) {
$this->generator = $generator;
$this->site = $site;
$this->extensionManager = $extensionManager;
$this->chainQueue = $chainQueue;
+ $this->validator = $validator;
parent::__construct();
}
'description',
null,
InputOption::VALUE_OPTIONAL,
- $this->trans('commands.generate.module.options.description')
- );
+ $this->trans('commands.generate.help.options.description')
+ )->setAliases(['gh']);
}
/**
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
- // @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
- if (!$this->confirmGeneration($io)) {
+ // @see use Drupal\Console\Command\ConfirmationTrait::confirmOperation
+ if (!$this->confirmOperation()) {
return 1;
}
$description = $input->getOption('description');
- $this
- ->generator
- ->generate($module, $description);
+ $this->generator->generate([
+ 'machine_name' => $module,
+ 'description' => $description,
+ ]);
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$this->site->loadLegacyFile('/core/includes/update.inc');
$this->site->loadLegacyFile('/core/includes/schema.inc');
- $module = $input->getOption('module');
- if (!$module) {
- // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
- $module = $this->moduleQuestion($io);
- $input->setOption('module', $module);
- }
+ // --module option
+ $this->getModuleOption();
$description = $input->getOption('description');
if (!$description) {
- $description = $io->ask(
- $this->trans('commands.generate.module.questions.description'),
- 'My Awesome Module'
+ $description = $this->getIo()->ask(
+ $this->trans('commands.generate.help.questions.description'),
+ $this->trans('commands.generate.module.suggestions.my-awesome-module')
);
}
$input->setOption('description', $description);