Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/Command/Help/HelpCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
namespace fsmaker\Command\Help;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\HelpCommand as BaseHelpCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Symfony\Component\Console\Helper\DescriptorHelper;

#[AsCommand(
name: 'help',
description: 'Muestra este mensaje de ayuda',
)]
class HelpCommand extends BaseHelpCommand
{
protected function configure(): void
{
parent::configure();
$this->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);
}
}
18 changes: 18 additions & 0 deletions src/Command/List/ListCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace fsmaker\Command\List;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\ListCommand as BaseListCommand;

#[AsCommand(
name: 'list',
description: 'Muestra este mensaje de ayuda',
)]
class ListCommand extends BaseListCommand
{
protected function configure(): void
{
parent::configure();
$this->setDescription('Muestra este mensaje de ayuda');
}
}
16 changes: 16 additions & 0 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 <info>list</info> command'),
]);
}

private function getCommands(): array
{
return [
Expand All @@ -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(),
Expand Down