Browse Source

Merge branch '1.6'

Jordi Boggiano 7 years ago
parent
commit
015927d0b0
1 changed files with 16 additions and 3 deletions
  1. 16 3
      src/Composer/Command/RunScriptCommand.php

+ 16 - 3
src/Composer/Command/RunScriptCommand.php

@@ -19,6 +19,7 @@ use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Helper\Table;
 
 /**
  * @author Fabien Potencier <fabien.potencier@gmail.com>
@@ -68,7 +69,7 @@ EOT
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         if ($input->getOption('list')) {
-            return $this->listScripts();
+            return $this->listScripts($output);
         } elseif (!$input->getArgument('script')) {
             throw new \RuntimeException('Missing required argument "script"');
         }
@@ -101,7 +102,7 @@ EOT
         return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
     }
 
-    protected function listScripts()
+    protected function listScripts(OutputInterface $output)
     {
         $scripts = $this->getComposer()->getPackage()->getScripts();
 
@@ -111,10 +112,22 @@ EOT
 
         $io = $this->getIO();
         $io->writeError('<info>scripts:</info>');
+        $table = array();
         foreach ($scripts as $name => $script) {
-            $io->write('  ' . $name);
+            $cmd = $this->getApplication()->find($name);
+            $description = '';
+            if ($cmd instanceof ScriptAliasCommand) {
+                $description = $cmd->getDescription();
+            }
+            $table[] = array('  '.$name, $description);
         }
 
+        $renderer = new Table($output);
+        $renderer->setStyle('compact');
+        $renderer->getStyle()->setVerticalBorderChar('');
+        $renderer->getStyle()->setCellRowContentFormat('%s  ');
+        $renderer->setRows($table)->render();
+
         return 0;
     }
 }