本文整理汇总了PHP中Symfony\Component\Console\Input\InputArgument::getDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP InputArgument::getDescription方法的具体用法?PHP InputArgument::getDescription怎么用?PHP InputArgument::getDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Input\InputArgument
的用法示例。
在下文中一共展示了InputArgument::getDescription方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault()));
} else {
$default = '';
}
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($argument->getName());
$this->writeText(sprintf(" <info>%-{$nameWidth}s</info> %s%s", $argument->getName(), str_replace("\n", "\n" . str_repeat(' ', $nameWidth + 2), $argument->getDescription()), $default), $options);
}
示例2: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
$default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
} else {
$default = '';
}
$totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName());
$spacingWidth = $totalWidth - strlen($argument->getName()) + 2;
$this->writeText(sprintf(' <info>%s</info>%s%s%s', $argument->getName(), str_repeat(' ', $spacingWidth), preg_replace('/\\s*[\\r\\n]\\s*/', "\n" . str_repeat(' ', $totalWidth + 17), $argument->getDescription()), $default), $options);
}
示例3: promptMissingArgument
/**
* @param InputInterface $input
* @param InputArgument $argument
*/
protected function promptMissingArgument(InputInterface $input, $argument)
{
$hasArgument = false;
while (!$hasArgument) {
$answer = $this->out->ask($argument->getDescription(), $argument->getDefault());
if ($answer !== null) {
$hasArgument = true;
$input->setArgument($argument->getName(), $answer);
} elseif (!$argument->isRequired()) {
$hasArgument = true;
}
}
}
示例4: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = [])
{
$this->write('* **`' . $argument->getName() . "`**");
$notes = [$argument->isRequired() ? "required" : "optional"];
if ($argument->isArray()) {
$notes[] = "multiple values allowed";
}
$this->write(' (' . implode('; ', $notes) . ')');
$this->write(" \n " . $argument->getDescription());
if (!$argument->isRequired() && $argument->getDefault()) {
$default = var_export($argument->getDefault(), true);
$this->write(" \n Default: `{$default}``");
}
}
示例5: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($objectXML = $dom->createElement('argument'));
$objectXML->setAttribute('name', $argument->getName());
$objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
$objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
$objectXML->appendChild($descriptionXML = $dom->createElement('description'));
$descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
$defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
foreach ($defaults as $default) {
$defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
$defaultXML->appendChild($dom->createTextNode($default));
}
return $this->output($dom, $options);
}
示例6: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
$this->write('**' . $argument->getName() . ':**' . "\n\n" . '* Name: ' . ($argument->getName() ?: '<none>') . "\n" . '* Is required: ' . ($argument->isRequired() ? 'yes' : 'no') . "\n" . '* Is array: ' . ($argument->isArray() ? 'yes' : 'no') . "\n" . '* Description: ' . preg_replace('/\\s*\\R\\s*/', PHP_EOL . ' ', $argument->getDescription() ?: '<none>') . "\n" . '* Default: `' . str_replace("\n", '', var_export($argument->getDefault(), true)) . '`');
}
示例7: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
return $this->output(array('name' => $argument->getName(), 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), 'description' => $argument->getDescription(), 'default' => $argument->getDefault()), $options);
}
示例8: getInputArgumentData
/**
* @param InputArgument $argument
*
* @return array
*/
private function getInputArgumentData(InputArgument $argument)
{
return array('name' => $argument->getName(), 'is_required' => $argument->isRequired(), 'is_array' => $argument->isArray(), 'description' => preg_replace('/\\s*\\R\\s*/', ' ', $argument->getDescription()), 'default' => $argument->getDefault());
}
示例9: getDescription
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function getDescription()
{
return $this->description ?: parent::getDescription();
}
示例10: testGetDescription
public function testGetDescription()
{
$argument = new InputArgument('foo', null, 'Some description');
$this->assertEquals('Some description', $argument->getDescription(), '->getDescription() return the message description');
}
示例11: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
return '**' . $argument->getName() . ':**' . "\n\n" . '* Name: ' . ($argument->getName() ?: '<none>') . "\n" . '* Is required: ' . ($argument->isRequired() ? 'yes' : 'no') . "\n" . '* Is array: ' . ($argument->isArray() ? 'yes' : 'no') . "\n" . '* Description: ' . ($argument->getDescription() ?: '<none>') . "\n" . '* Default: `' . str_replace("\n", '', var_export($argument->getDefault(), true)) . '`';
}
示例12: describeInputArgument
/**
* {@inheritdoc}
*/
protected function describeInputArgument(InputArgument $argument, array $options = array())
{
$this->write('#### `' . ($argument->getName() ?: '<none>') . "`\n\n" . ($argument->getDescription() ? preg_replace('/\\s*[\\r\\n]\\s*/', "\n", $argument->getDescription()) . "\n\n" : '') . '* Is required: ' . ($argument->isRequired() ? 'yes' : 'no') . "\n" . '* Is array: ' . ($argument->isArray() ? 'yes' : 'no') . "\n" . '* Default: `' . str_replace("\n", '', var_export($argument->getDefault(), true)) . '`');
}