Ejemplo n.º 1
0
 /**
  * @return int|null|void
  */
 protected function serve()
 {
     $this->options = $this->input->getOptions();
     $this->gpm = new GPM($this->options['force']);
     $this->displayGPMRelease();
     $this->data = $this->gpm->getRepository();
     $data = $this->filter($this->data);
     $climate = new CLImate();
     $climate->extend('Grav\\Console\\TerminalObjects\\Table');
     if (!$data) {
         $this->output->writeln('No data was found in the GPM repository stored locally.');
         $this->output->writeln('Please try clearing cache and running the <green>bin/gpm index -f</green> command again');
         $this->output->writeln('If this doesn\'t work try tweaking your GPM system settings.');
         $this->output->writeln('');
         $this->output->writeln('For more help go to:');
         $this->output->writeln(' -> <yellow>https://learn.getgrav.org/troubleshooting/common-problems#cannot-connect-to-the-gpm</yellow>');
         die;
     }
     foreach ($data as $type => $packages) {
         $this->output->writeln("<green>" . strtoupper($type) . "</green> [ " . count($packages) . " ]");
         $packages = $this->sort($packages);
         if (!empty($packages)) {
             $table = [];
             $index = 0;
             foreach ($packages as $slug => $package) {
                 $row = ['Count' => $index++ + 1, 'Name' => "<cyan>" . Utils::truncate($package->name, 20, false, ' ', '...') . "</cyan> ", 'Slug' => $slug, 'Version' => $this->version($package), 'Installed' => $this->installed($package)];
                 $table[] = $row;
             }
             $climate->table($table);
         }
         $this->output->writeln('');
     }
     $this->output->writeln('You can either get more informations about a package by typing:');
     $this->output->writeln('    <green>' . $this->argv . ' info <cyan><package></cyan></green>');
     $this->output->writeln('');
     $this->output->writeln('Or you can install a package by typing:');
     $this->output->writeln('    <green>' . $this->argv . ' install <cyan><package></cyan></green>');
     $this->output->writeln('');
 }
Ejemplo n.º 2
0
 public function testTruncate()
 {
     $this->assertEquals('engli' . '&hellip;', Utils::truncate('english', 5));
     $this->assertEquals('english', Utils::truncate('english'));
     $this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
     $this->assertEquals('Th' . '&hellip;', Utils::truncate('This is a string to truncate', 2));
     $this->assertEquals('engli' . '...', Utils::truncate('english', 5, true, " ", "..."));
     $this->assertEquals('english', Utils::truncate('english'));
     $this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
     $this->assertEquals('This ', Utils::truncate('This is a string to truncate', 3, true));
     $this->assertEquals('<input ', Utils::truncate('<input type="file" id="file" multiple />', 6, true));
 }
Ejemplo n.º 3
0
 public function testTruncate()
 {
     $this->assertEquals(Utils::truncate('english', 5), 'engli' . '&hellip;');
     $this->assertEquals(Utils::truncate('english'), 'english');
     $this->assertEquals(Utils::truncate('This is a string to truncate'), 'This is a string to truncate');
     $this->assertEquals(Utils::truncate('This is a string to truncate', 2), 'Th' . '&hellip;');
     $this->assertEquals(Utils::truncate('english', 5, true, " ", "..."), 'engli' . '...');
     $this->assertEquals(Utils::truncate('english'), 'english');
     $this->assertEquals(Utils::truncate('This is a string to truncate'), 'This is a string to truncate');
     $this->assertEquals(Utils::truncate('This is a string to truncate', 3, true), 'This ');
 }