Add descriptions to commands

This commit is contained in:
Oliver Davies 2024-02-25 16:44:48 +00:00
parent 82900c719c
commit d6f04371eb
6 changed files with 14 additions and 0 deletions

View file

@ -8,6 +8,8 @@ use Symfony\Component\Filesystem\Filesystem;
abstract class AbstractCommand extends Command abstract class AbstractCommand extends Command
{ {
protected static string $description;
public function __construct( public function __construct(
protected Filesystem $filesystem, protected Filesystem $filesystem,
?string $name = null, ?string $name = null,
@ -17,6 +19,8 @@ abstract class AbstractCommand extends Command
protected function configure(): void protected function configure(): void
{ {
$this->setDescription(static::$description);
$this->addOption( $this->addOption(
name: 'args', name: 'args',
shortcut: 'a', shortcut: 'a',

View file

@ -14,6 +14,8 @@ use Symfony\Component\Filesystem\Filesystem;
final class BuildCommand extends AbstractCommand final class BuildCommand extends AbstractCommand
{ {
public static string $description = 'Build the project';
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$projectType = null; $projectType = null;

View file

@ -12,6 +12,8 @@ use Symfony\Component\Filesystem\Filesystem;
final class InstallCommand extends AbstractCommand final class InstallCommand extends AbstractCommand
{ {
public static string $description = 'Install the project\'s dependencies';
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$args = $input->getOption('args'); $args = $input->getOption('args');

View file

@ -12,6 +12,8 @@ use Symfony\Component\Console\Output\OutputInterface;
final class PackageInstallCommand extends AbstractCommand final class PackageInstallCommand extends AbstractCommand
{ {
public static string $description = 'Install a new package';
public function configure(): void public function configure(): void
{ {
parent::configure(); parent::configure();

View file

@ -13,6 +13,8 @@ use Symfony\Component\Filesystem\Filesystem;
final class RunCommand extends AbstractCommand final class RunCommand extends AbstractCommand
{ {
public static string $description = 'Run the project';
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$projectType = null; $projectType = null;

View file

@ -9,6 +9,8 @@ use Symfony\Component\Console\Output\OutputInterface;
final class TestCommand extends AbstractCommand final class TestCommand extends AbstractCommand
{ {
public static string $description = 'Run the project\'s tests';
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$args = $input->getOption('args'); $args = $input->getOption('args');