addOption example

public function __construct(AbstractVault $vault, AbstractVault $localVault = null)
    {
        $this->vault = $vault;
        $this->localVault = $localVault;

        parent::__construct();
    }

    protected function configure(): void
    {
        $this
            ->addOption('reveal', 'r', InputOption::VALUE_NONE, 'Display decrypted values alongside names')
            ->setHelp(<<<'EOF' The <info>%command.name%</info> command list all stored secrets. <info>%command.full_name%</info> When the option <info>--reveal</info> is provided, the decrypted secrets are also displayed. <info>%command.full_name% --reveal</info> EOF
            )
        ;
    }

    public function __construct(private readonly EntityRepository $pluginRepo)
    {
        parent::__construct();
    }

    /** * {@inheritdoc} */
    protected function configure(): void
    {
        $this->addOption('json', null, InputOption::VALUE_NONE, 'Return result as json of plugin entities')
            ->addOption('filter', 'f', InputOption::VALUE_REQUIRED, 'Filter the plugin list to a given term');
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new ShopwareStyle($input$output);
        $context = Context::createDefaultContext();

        

  protected $classLoader;

  /** * {@inheritdoc} */
  protected function configure() {
    $this->setName('user-login')
      ->setDescription('Generate a one time login link for an user.')
      ->addArgument('uid', InputArgument::REQUIRED, 'The ID of the user for whom the link will be generated')
      ->addOption('site-path', NULL, InputOption::VALUE_REQUIRED, 'The path for the test site.');
  }

  /** * {@inheritdoc} * * @throws \Symfony\Component\Console\Exception\InvalidArgumentException */
  protected function execute(InputInterface $input, OutputInterface $output): int {
    $root = dirname(__DIR__, 5);
    chdir($root);

    
private readonly Filesystem $filesystem,
        private readonly string $projectDir,
        private readonly string $publicDirName,
        private readonly bool $isDebug,
    ) {
        parent::__construct();
    }

    protected function configure(): void
    {
        $this
            ->addOption('clean', null, null, 'Whether to clean the public directory before compiling assets')
            ->setHelp(<<<'EOT' The <info>%command.name%</info> command compiles and dumps all the assets in the asset mapper into the final public directory (usually <comment>public/assets</comment>). This command is meant to be run during deployment. EOT
            );
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        
return [];
    }

    /** * {@inheritdoc} */
    protected function configure()
    {
        $this
            ->setName('sw:es:index:populate')
            ->setDescription('Reindex all shops into a new index and switch the live-system alias after the index process.')
            ->addOption('shopId', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The shop to populate (multiple Ids -> shopId={1,2})')
            ->addOption('index', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'The index to populate')
            ->addOption('no-evaluation', null, InputOption::VALUE_NONE, 'Disable evaluation for each index')
            ->addOption('stop-on-error', null, InputOption::VALUE_NONE, 'Abort indexing if an error occurs')
        ;
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        

    protected function configure()
    {
        $this
            ->setName('sw:snippets:find:missing')
            ->setDescription('Find missing snippets in the database and dumps them into .ini files')
            ->addArgument(
                'locale',
                InputArgument::REQUIRED,
                'Locale to be exported.'
            )
            ->addOption(
                'target',
                null,
                InputOption::VALUE_REQUIRED,
                'The folder where the exported files should be placed. Defaults to snippetsExport',
                'snippetsExport'
            )
            ->addOption(
                'fallback',
                null,
                InputOption::VALUE_REQUIRED,
                'If a locale is provided, it will be used to fill in the values for the snippets. Ideal to export missing snippets directly for translation. Defaults to null, which exports empty snippets',
                
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class GenerateMigrationCommand extends ShopwareCommand
{
    public function configure(): void
    {
        $this
            ->addOption('plugin', 'p', InputOption::VALUE_OPTIONAL, 'Plugin Name')
            ->addArgument('migrationName', InputArgument::REQUIRED, 'Migration Name')
            ->setDescription('Generates a migration file for the core or for a specific plugin');
    }

    /** * {@inheritdoc} */
    public function execute(InputInterface $input, OutputInterface $output)
    {
        $pluginName = $input->getOption('plugin');
        $migrationName = $input->getArgument('migrationName');
        


    protected function configureCommand(string $lifecycleMethod): void
    {
        $this
            ->setDescription(sprintf('%ss given plugins', ucfirst($lifecycleMethod)))
            ->addArgument(
                'plugins',
                InputArgument::REQUIRED | InputArgument::IS_ARRAY,
                'List of plugins'
            )
            ->addOption(
                'refresh',
                'r',
                InputOption::VALUE_NONE,
                'Use this option to refresh the plugins before executing the command'
            )
            ->addOption(
                'clearCache',
                'c',
                InputOption::VALUE_NONE,
                'Use this option to clear the cache after executing the plugin command'
            )
            

class RebuildCategoryTreeCommand extends ShopwareCommand
{
    /** * {@inheritdoc} */
    protected function configure()
    {
        $this
            ->setName('sw:rebuild:category:tree')
            ->setDescription('Rebuild the category tree')
             ->addOption('offset', 'o', InputOption::VALUE_OPTIONAL, 'Offset to start with.')
             ->addOption('limit', 'l', InputOption::VALUE_OPTIONAL, 'Categories to build per batch. Default: 1000')
            ->setHelp(
                <<<'EOF' The <info>%command.name%</info> command will rebuild your category tree. EOF
            );
    }

    /** * {@inheritdoc} */
    

    protected $output;

    /** * @var InputInterface */
    protected $input;

    protected function addConfigureAuth()
    {
        $this
            ->addOption(
                'username',
                null,
                InputOption::VALUE_OPTIONAL
            )
            ->addOption(
                'password',
                null,
                InputOption::VALUE_OPTIONAL
            )
        ;
    }

    
$tester = new CommandTester($this->command);
        $tester->execute([]);

        static::assertTrue($eventCalled, 'Event was not fired.');
        static::assertStringContainsString('Demodata Generator', $tester->getDisplay());
        static::assertSame(Command::SUCCESS, $tester->getStatusCode());
    }

    public function testDefaults(): void
    {
        $this->command->addOption('tags', null, InputOption::VALUE_OPTIONAL);
        $this->command->addOption('products', null, InputOption::VALUE_OPTIONAL);
        $this->command->addOption('categories', null, InputOption::VALUE_OPTIONAL);

        $this->command->addDefault('products', 1);
        $this->command->addDefault('categories', 1);

        $eventCalled = false;
        $this->dispatcher->addListener(DemodataRequestCreatedEvent::classstatic function DDemodataRequestCreatedEvent $event) use (&$eventCalled): void {
            $eventCalled = true;

            static::assertSame(0, $event->getRequest()->get(TagDefinition::class));
            
private function createApplicationWithCommand(): Application
    {
        $application = new Application();
        $application->setAutoExit(false);
        $application->addCommands([
            new class() extends Command {
                public function configure(): void
                {
                    $this
                        ->setName('test:command')
                        ->addOption('throw')
                        ->addOption('exit', null, InputOption::VALUE_REQUIRED, 0)
                    ;
                }

                protected function execute(InputInterface $input, OutputInterface $output): int
                {
                    $output->write('some message');

                    if ($input->getOption('throw')) {
                        throw new \RuntimeException('exception message');
                    }

                    
class AdminCreateCommand extends ShopwareCommand
{
    /** * {@inheritdoc} */
    protected function configure()
    {
        $this
            ->setName('sw:admin:create')
            ->setDescription('Create a new administrator user')
            ->setHelp('The <info>sw:admin:create</info> command create a new administration user.')
            ->addOption(
                'email',
                null,
                InputOption::VALUE_REQUIRED,
                'Admin email'
            )
            ->addOption(
                'username',
                null,
                InputOption::VALUE_REQUIRED,
                'Admin login name'
            )
            

class TestSiteTearDownCommand extends Command {

  /** * {@inheritdoc} */
  protected function configure() {
    $this->setName('tear-down')
      ->setDescription('Removes a test site added by the install command')
      ->setHelp('All the database tables and files will be removed.')
      ->addArgument('db-prefix', InputArgument::REQUIRED, 'The database prefix for the test site.')
      ->addOption('db-url', NULL, InputOption::VALUE_OPTIONAL, 'URL for database. Defaults to the environment variable SIMPLETEST_DB.', getenv('SIMPLETEST_DB'))
      ->addOption('keep-lock', NULL, InputOption::VALUE_NONE, 'Keeps the database prefix lock. Useful for ensuring test isolation when running concurrent tests.')
      ->addUsage('test12345678')
      ->addUsage('test12345678 --db-url "mysql://username:password@localhost/databasename#table_prefix"')
      ->addUsage('test12345678 --keep-lock');
  }

  /** * {@inheritdoc} */
  protected function execute(InputInterface $input, OutputInterface $output): int {
    $db_prefix = $input->getArgument('db-prefix');
    

    public function __construct(
        private readonly Connection $connection,
        private readonly EntityRepository $customerRepository
    ) {
        parent::__construct();
    }

    protected function configure(): void
    {
        $this->addArgument('type', InputArgument::OPTIONAL)
            ->addOption(
                'days',
                'd',
                InputOption::VALUE_REQUIRED,
                'An optional numeric value for removing guests without orders or canceled carts after the number of days'
            )
            ->addOption(
                'all',
                'a',
                InputOption::VALUE_NONE,
                'Cleans any possible personal data: guests without orders and canceled carts'
            );
    }
Home | Imprint | This part of the site doesn't use cookies.