20 lines
		
	
	
	
		
			660 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
	
		
			660 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| // https://symfony.com/doc/current/components/console/single_command_tool.html
 | |
| 
 | |
| require __DIR__.'/vendor/autoload.php';
 | |
| 
 | |
| use Symfony\Component\Console\Attribute\Argument;
 | |
| use Symfony\Component\Console\Attribute\Option;
 | |
| use Symfony\Component\Console\Output\OutputInterface;
 | |
| use Symfony\Component\Console\SingleCommandApplication;
 | |
| 
 | |
| (new SingleCommandApplication())
 | |
|     ->setName('My Super Command') // Optional
 | |
|     ->setVersion('1.0.0') // Optional
 | |
|     ->setCode(function (OutputInterface $output, #[Argument] string $foo = 'The directory', #[Option] string $bar = ''): int {
 | |
|         // output arguments and options
 | |
| 
 | |
|         return 0;
 | |
|     })
 | |
|     ->run();
 |