2
0

FooCommand.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Test\Michel\Console\Command;
  3. use Michel\Console\Argument\CommandArgument;
  4. use Michel\Console\Command\CommandInterface;
  5. use Michel\Console\InputInterface;
  6. use Michel\Console\Option\CommandOption;
  7. use Michel\Console\OutputInterface;
  8. class FooCommand implements CommandInterface
  9. {
  10. public function getName(): string
  11. {
  12. return 'foo';
  13. }
  14. public function getDescription(): string
  15. {
  16. return 'Performs the foo operation with optional parameters.';
  17. }
  18. public function getOptions(): array
  19. {
  20. return [
  21. new CommandOption('verbose', 'v', 'Enable verbose output', true),
  22. new CommandOption('output', 'o', 'Specify output file', false)
  23. ];
  24. }
  25. public function getArguments(): array
  26. {
  27. return [
  28. new CommandArgument('input', false, 'none', 'The input file for the foo operation')
  29. ];
  30. }
  31. public function execute(InputInterface $input, OutputInterface $output): void
  32. {
  33. $output->writeln('Test OK');
  34. $output->writeln('ARGUMENTS: ' . json_encode($input->getArguments()));
  35. $output->writeln('OPTIONS: ' . json_encode($input->getOptions()));
  36. }
  37. }