diff options
Diffstat (limited to 'crates/shirabe/tests/plugin/fixtures/e2e-script-command/src')
3 files changed, 66 insertions, 0 deletions
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/GreetCommand.php b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/GreetCommand.php new file mode 100644 index 00000000..e797486b --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/GreetCommand.php @@ -0,0 +1,34 @@ +<?php + +namespace ShirabeTest\ScriptCommand; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class GreetCommand extends Command +{ + protected function configure(): void + { + $this + ->setDescription('Greets someone from a script-provided command.') + ->setHelp('The <info>greet</info> command exercises a Command class named by a composer.json script.') + ->addArgument('who', InputArgument::REQUIRED, 'Who to greet') + ->addOption('shout', 's', InputOption::VALUE_NONE, 'Uppercase the greeting'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $message = 'Hello ' . $input->getArgument('who'); + if ($input->getOption('shout')) { + $message = strtoupper($message); + } + $output->writeln('greet: ' . $message); + $output->writeln('greet: name=' . $this->getName()); + $output->writeln('greet: app=' . get_class($this->getApplication())); + + return 0; + } +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php new file mode 100644 index 00000000..f3f6b05f --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/MismatchedNameCommand.php @@ -0,0 +1,23 @@ +<?php + +namespace ShirabeTest\ScriptCommand; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class MismatchedNameCommand extends Command +{ + protected function configure(): void + { + $this->setName('not-the-script-name'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $output->writeln('renamed: name=' . $this->getName()); + $output->writeln('renamed: description=' . $this->getDescription()); + + return 0; + } +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/SingleAppCommand.php b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/SingleAppCommand.php new file mode 100644 index 00000000..89e17fe9 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e-script-command/src/SingleAppCommand.php @@ -0,0 +1,9 @@ +<?php + +namespace ShirabeTest\ScriptCommand; + +use Symfony\Component\Console\SingleCommandApplication; + +class SingleAppCommand extends SingleCommandApplication +{ +} |
