コード例 #1
0
 public function handleList(Args $args, IO $io)
 {
     $table = new Table(PuliTableStyle::borderless());
     $table->setHeaderRow(array('Name', 'Class', 'Description'));
     foreach ($this->installerManager->getInstallerDescriptors() as $descriptor) {
         $className = $descriptor->getClassName();
         if (!$args->isOptionSet('long')) {
             $className = StringUtil::getShortClassName($className);
         }
         $parameters = array();
         foreach ($descriptor->getParameters() as $parameterName => $parameter) {
             if (!$parameter->isRequired()) {
                 $parameterName .= '=' . StringUtil::formatValue($parameter->getDefaultValue());
             }
             $parameters[] = $parameterName;
         }
         $description = $descriptor->getDescription();
         if (!empty($parameters)) {
             // non-breaking space
             $description .= ' <c1>(' . implode(", ", $parameters) . ')</c1>';
         }
         $table->addRow(array('<u>' . $descriptor->getName() . '</u>', '<c1>' . $className . '</c1>', $description));
     }
     $table->render($io);
     return 0;
 }
コード例 #2
0
 /**
  * Handles the "config <key>" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handleShow(Args $args, IO $io)
 {
     $raw = !$args->isOptionSet('parsed');
     $value = $this->manager->getConfigKey($args->getArgument('key'), null, true, $raw);
     $io->writeLine(StringUtil::formatValue($value, false));
     return 0;
 }
コード例 #3
0
 public function handleList(Args $args, IO $io)
 {
     $table = new Table(TableStyle::borderless());
     $targets = $this->targetManager->getTargets();
     if ($targets->isEmpty()) {
         $io->writeLine('No install targets. Use "puli target add <name> <directory>" to add a target.');
         return 0;
     }
     $defaultTarget = $targets->getDefaultTarget();
     foreach ($targets as $target) {
         $parameters = '';
         foreach ($target->getParameterValues() as $name => $value) {
             $parameters .= "\n<c1>" . $name . '=' . StringUtil::formatValue($value) . '</c1>';
         }
         $table->addRow(array($defaultTarget === $target ? '*' : '', '<u>' . $target->getName() . '</u>', $target->getInstallerName(), '<c2>' . $target->getLocation() . '</c2>' . $parameters, '<c1>' . $target->getUrlFormat() . '</c1>'));
     }
     $table->render($io);
     return 0;
 }
コード例 #4
0
 /**
  * Prints the binding types in a table.
  *
  * @param IO                      $io          The I/O.
  * @param BindingTypeDescriptor[] $descriptors The type descriptors to print.
  * @param string                  $styleTag    The tag used to style the output
  * @param int                     $indentation The number of spaces to indent.
  */
 private function printTypeTable(IO $io, array $descriptors, $styleTag = null, $indentation = 0)
 {
     $table = new Table(PuliTableStyle::borderless());
     $table->setHeaderRow(array('Type', 'Description', 'Parameters'));
     $paramTag = $styleTag ?: 'c1';
     $typeTag = $styleTag ?: 'u';
     foreach ($descriptors as $descriptor) {
         $type = $descriptor->getType();
         $parameters = array();
         foreach ($type->getParameters() as $parameter) {
             $paramString = $parameter->isRequired() ? $parameter->getName() : $parameter->getName() . '=' . StringUtil::formatValue($parameter->getDefaultValue());
             $parameters[$parameter->getName()] = "<{$paramTag}>{$paramString}</{$paramTag}>";
         }
         $description = $descriptor->getDescription();
         if ($styleTag) {
             $description = "<{$styleTag}>{$description}</{$styleTag}>";
         }
         ksort($parameters);
         $table->addRow(array("<{$typeTag}>" . $descriptor->getTypeName() . "</{$typeTag}>", $description, implode("\n", $parameters)));
     }
     $table->render($io, $indentation);
 }
コード例 #5
0
ファイル: BindCommandHandler.php プロジェクト: holloway87/cli
 /**
  * Prints a list of binding descriptors.
  *
  * @param IO                  $io          The I/O.
  * @param BindingDescriptor[] $descriptors The binding descriptors.
  * @param int                 $indentation The number of spaces to indent.
  * @param bool                $enabled     Whether the binding descriptors
  *                                         are enabled. If not, the output
  *                                         is printed in red.
  */
 private function printBindingTable(IO $io, array $descriptors, $indentation = 0, $enabled = true)
 {
     $table = new Table(PuliTableStyle::borderless());
     $table->setHeaderRow(array('UUID', 'Glob', 'Type'));
     $paramTag = $enabled ? 'c1' : 'bad';
     $artifactTag = $enabled ? 'c1' : 'bad';
     $typeTag = $enabled ? 'u' : 'bad';
     foreach ($descriptors as $descriptor) {
         $parameters = array();
         $binding = $descriptor->getBinding();
         foreach ($binding->getParameterValues() as $parameterName => $parameterValue) {
             $parameters[] = $parameterName . '=' . StringUtil::formatValue($parameterValue);
         }
         $uuid = substr($descriptor->getUuid(), 0, 6);
         if (!$enabled) {
             $uuid = "<bad>{$uuid}</bad>";
         }
         $paramString = '';
         if (!empty($parameters)) {
             // \xc2\xa0 is a non-breaking space
             $paramString = " <{$paramTag}>(" . implode(", ", $parameters) . ")</{$paramTag}>";
         }
         if ($binding instanceof ResourceBinding) {
             $artifact = $binding->getQuery();
         } elseif ($binding instanceof ClassBinding) {
             $artifact = StringUtil::getShortClassName($binding->getClassName());
         } else {
             continue;
         }
         $typeString = StringUtil::getShortClassName($binding->getTypeName());
         $table->addRow(array($uuid, "<{$artifactTag}>{$artifact}</{$artifactTag}>", "<{$typeTag}>{$typeString}</{$typeTag}>" . $paramString));
     }
     $table->render($io, $indentation);
 }
コード例 #6
0
ファイル: BindCommandHandler.php プロジェクト: rejinka/cli
 /**
  * Prints a list of binding descriptors.
  *
  * @param IO                  $io          The I/O.
  * @param BindingDescriptor[] $descriptors The binding descriptors.
  * @param int                 $indentation The number of spaces to indent.
  * @param bool                $enabled     Whether the binding descriptors
  *                                         are enabled. If not, the output
  *                                         is printed in red.
  */
 private function printBindingTable(IO $io, array $descriptors, $indentation = 0, $enabled = true)
 {
     $table = new Table(PuliTableStyle::borderless());
     $table->setHeaderRow(array('UUID', 'Glob', 'Type'));
     $paramTag = $enabled ? 'c1' : 'bad';
     $queryTag = $enabled ? 'c1' : 'bad';
     $typeTag = $enabled ? 'u' : 'bad';
     foreach ($descriptors as $descriptor) {
         $parameters = array();
         foreach ($descriptor->getParameterValues() as $parameterName => $value) {
             $parameters[] = $parameterName . '=' . StringUtil::formatValue($value);
         }
         $uuid = substr($descriptor->getUuid(), 0, 6);
         if (!$enabled) {
             $uuid = "<bad>{$uuid}</bad>";
         }
         if ($parameters) {
             // \xc2\xa0 is a non-breaking space
             $paramString = " <{$paramTag}>(" . implode(", ", $parameters) . ")</{$paramTag}>";
         } else {
             $paramString = '';
         }
         $table->addRow(array($uuid, "<{$queryTag}>{$descriptor->getQuery()}</{$queryTag}>", "<{$typeTag}>{$descriptor->getTypeName()}</{$typeTag}>" . $paramString));
     }
     $table->render($io, $indentation);
 }