Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $defaults = array();
     if ($input->getOption('msgctxt')) {
         $defaults['msgctxt'] = $input->getOption('msgctxt');
     }
     $this->pot = new Pot($input->getOption('base'), array(), $defaults);
     $files = $input->getArgument('files');
     if (in_array('-', $files)) {
         $files = array_merge($files, explode("\n", stream_get_contents($this->stdin)));
     }
     $actualFiles = $this->findFiles($files);
     if (!$input->getOption('out')) {
         foreach ($actualFiles as $file) {
             $this->extractFile($file);
         }
         if ($input->getOption('header')) {
             $output->write(file_get_contents($input->getOption('header')));
         }
         $output->write($this->pot->toString($input));
     } else {
         $progress = new ProgressHelper();
         $progress->start($output, 1 + count($actualFiles));
         $progress->advance();
         foreach ($actualFiles as $file) {
             $this->extractFile($file);
             $progress->advance();
         }
         $content = '';
         ## If header is supplied and if we're starting a new file.
         if ($input->getOption('header')) {
             if (!file_exists($input->getOption('out')) || !$input->getOption('append')) {
                 $content .= file_get_contents($input->getOption('header'));
             }
         }
         $content .= $this->pot->toString($input);
         file_put_contents($input->getOption('out'), $content, $input->getOption('append') ? FILE_APPEND : NULL);
         $progress->finish();
     }
 }