Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

allow access/configuration to SymfonyStyle's progressBar in 7.3 #60381

Copy link
Copy link
Open
@tacman

Description

@tacman
Issue body actions

Description

As I'm converting my console commands to Symfony 7.3, I've started to tighten them up by using SymfonyStyle's built-in progress bar.

But sometimes I want to customize it, or even just to access it.

Example

    public function __invoke(
        SymfonyStyle     $io,
        #[Option(description: 'batch size for flush')]
        int    $batch = 5,

Before:

         $progressBar = $io->createProgressBar($limit ?: $finder->count());
         $progressBar->start();
         foreach ($io->iterate($finder, $limit ?: $finder->count()) as $idx=>$dir) {
            $progressBar->advance();
            if (($progressBar->getProgress() % $batch) === 0) {
                $this->entityManager->flush();
                $this->entityManager->clear();
            }
          }
          $progressBar->finish(); 

After:

        foreach ($io->progressIterate($finder, $limit ?: $finder->count()) as $idx=>$dir) {
            if (($io->getProgressBar()->getProgress() % $batch) === 0) {
                $this->entityManager->flush();
                $this->entityManager->clear();
            }
    }

I'd also like to configure the progressBar verbosity independently of the command verbosity. I pretty much always want to know how much memory is being used. So maybe something like creating the progressBar and setting it in $io?

I know I can do it by simply creating a progressBar and manually calling the advance and finish, but it's less code to use the built-in one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.