diff --git a/src/Command/Help/HelpCommand.php b/src/Command/Help/HelpCommand.php new file mode 100644 index 0000000..78a5c53 --- /dev/null +++ b/src/Command/Help/HelpCommand.php @@ -0,0 +1,41 @@ +setDescription('Muestra este mensaje de ayuda'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $commandName = $input->getArgument('command_name'); + + if ($commandName === 'help' || $commandName === 'list') { + $helper = new DescriptorHelper(); + $helper->describe($output, $this->getApplication(), [ + 'format' => $input->getOption('format'), + 'raw_text' => $input->getOption('raw'), + ]); + + return 0; + } + + $this->setCommand($this->getApplication()->find($commandName)); + + return parent::execute($input, $output); + } +} \ No newline at end of file diff --git a/src/Command/List/ListCommand.php b/src/Command/List/ListCommand.php new file mode 100644 index 0000000..15f67ff --- /dev/null +++ b/src/Command/List/ListCommand.php @@ -0,0 +1,18 @@ +setDescription('Muestra este mensaje de ayuda'); + } +} diff --git a/src/Console/Application.php b/src/Console/Application.php index 8810ce2..9d1f27f 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -6,6 +6,9 @@ namespace fsmaker\Console; use Symfony\Component\Console\Application as BaseApplication; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; class Application extends BaseApplication { @@ -15,6 +18,17 @@ public function __construct() $this->addCommands($this->getCommands()); } + /** + * Esto es para definir solo las opciones existentes (en fsmaker no existen opciones) + */ + protected function getDefaultInputDefinition(): InputDefinition + { + return new InputDefinition([ + new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), + new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display help for the given command. When no command is given display help for the list command'), + ]); + } + private function getCommands(): array { return [ @@ -25,11 +39,13 @@ private function getCommands(): array new \fsmaker\Command\Extension\ExtensionCommand(), new \fsmaker\Command\Generator\GithubActionCommand(), new \fsmaker\Command\Generator\GitignoreCommand(), + new \fsmaker\Command\Help\HelpCommand(), new \fsmaker\Command\Generator\TranslationsCommand(), new \fsmaker\Command\Generator\UpgradeCommand(), new \fsmaker\Command\Generator\UpgradeBs5Command(), new \fsmaker\Command\Generator\ZipCommand(), new \fsmaker\Command\Init\InitCommand(), + new \fsmaker\Command\List\ListCommand(), new \fsmaker\Command\Model\ModelCommand(), new \fsmaker\Command\Plugin\PluginCommand(), new \fsmaker\Command\Test\TestCommand(),