success() public method

Formats a success result bar.
public success ( string | array $message )
$message string | array
示例#1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new ConsoleIO($input, $output);
     if ($this->isInstalledAsPhar() === false) {
         $io->error('Self-update is available only for PHAR version');
         return 1;
     }
     $manifest = $this->getManifestFile();
     $remoteVersion = $manifest['version'];
     $localVersion = $this->getApplication()->getVersion();
     if ($localVersion === $remoteVersion) {
         $io->success('Spress is already up to date');
         return;
     }
     $remoteFilename = $manifest['url'];
     $localFilename = $_SERVER['argv'][0];
     $tempFilename = basename($localFilename, '.phar') . '-tmp.phar';
     $io->newLine();
     $io->write('Downloading Spress...');
     $io->newLine();
     $this->downloadRemoteFilename($remoteFilename);
     try {
         copy($remoteFilename, $tempFilename);
         chmod($tempFilename, 0777 & ~umask());
         $phar = new \Phar($tempFilename);
         unset($phar);
         if (@rename($tempFilename, $localFilename) !== true) {
             $io->error(sprintf('Cannot rename "%s" to "%s" probably because permission denied.', $tempFilename, $localFilename));
             return 1;
         }
         $io->success(sprintf('Spress updated from %s to %s.', $localVersion, $remoteVersion));
         if (isset($manifest['changelog_url']) === true) {
             $io->write(sprintf('<comment>Go to <info>%s</info> for more details.</comment>', $manifest['changelog_url']));
         }
     } catch (\Exception $e) {
         if ($e instanceof \UnexpectedValueException === false && $e instanceof \PharException === false) {
             throw $e;
         }
         unlink($tempFilename);
         $io->error([sprintf('The download is corrupt (%s).', $e->getMessage()), 'Please re-run the self-update command to try again.']);
         return 1;
     }
 }
示例#2
0
 /**
  * Writes the result of a parsing a site.
  *
  * @param \Yosymfony\Spress\IO\ConsoleIO                    $io
  * @param \Yosymfony\Spress\Core\DataSource\ItemInterface[] $items
  */
 protected function resultMessage(ConsoleIO $io, array $items)
 {
     $io->newLine();
     $io->labelValue('Total items', count($items));
     $io->newLine();
     $io->success('Success!');
 }
示例#3
0
 public function testSuccess()
 {
     $this->command->setCode(function (InputInterface $input, OutputInterface $output) use(&$isDecorated) {
         $io = new ConsoleIO($input, $output);
         $io->success('success!');
     });
     $this->tester->execute([], ['interactive' => false, 'decorated' => false]);
     $this->assertRegExp("/\\[OK\\] success!/", $this->tester->getDisplay(true));
 }