예제 #1
0
 /**
  * Describes a specific API type.
  *
  * @param Console\Input\InputInterface $input The input interface
  * @param Console\Output\OutputInterface $output The output interface
  * @throws PartKeepr\Console\Commands\Exceptions\ServiceCallNotFoundException If the call was not found in the service
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $type = $input->getArgument("type");
     $className = "PartKeepr\\" . $type . "\\" . $type;
     $reflector = new TypeReflector($className);
     $output->writeln(sprintf("<info>%s</info>: %s", $reflector->getName(), $reflector->getDescription()));
     $output->writeln("");
     $output->writeln($reflector->getDocumentation());
     $output->writeln("");
     $output->writeln("<info>Output Fields:</info>");
     $head = array('Name', 'Type', 'Description');
     $outputParameterTable = array();
     foreach ($reflector->getOutputFields() as $parameter) {
         $outputParameterTable[] = array($parameter->getName(), $parameter->getType(), $parameter->getDescription());
     }
     $table = new TablePrinter($output);
     $table->setHeader($head);
     $table->setBody($outputParameterTable);
     $table->output();
 }
예제 #2
0
 /**
  * Outputs the parameter table
  *
  * @param \PartKeepr\Service\ServiceCallReflector $call The reflected call
  * @param \Symfony\Component\Console\Output\OutputInterface $output The output interface
  */
 private function outputParameterTable(ServiceCallReflector $call, Console\Output\OutputInterface $output)
 {
     $output->writeln("<info>Parameters:</info>");
     $head = array('Name', 'Required', 'Type', 'Description');
     $parameterTable = array();
     foreach ($call->getParameters() as $parameter) {
         $parameterTable[] = array($parameter->getName(), $parameter->getRequiredFlag() ? 'Yes' : 'No', $parameter->getType(), $parameter->getDescription());
     }
     $table = new TablePrinter($output);
     $table->setHeader($head);
     $table->setBody($parameterTable);
     $table->output();
 }