本文整理汇总了PHP中Symfony\Component\Finder\Shell\Command类的典型用法代码示例。如果您正苦于以下问题:PHP Command类的具体用法?PHP Command怎么用?PHP Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Command类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildContentFiltering
protected function buildContentFiltering(Command $command, array $contains, $not = false)
{
foreach ($contains as $contain) {
$expr = Expression::create($contain);
$command->add('| xargs -I{} -r grep -I')->add($expr->isCaseSensitive() ? null : '-i')->add($not ? '-L' : '-l')->add('-Ee')->arg($expr->renderPattern())->add('{}');
}
}
示例2: buildContentFiltering
/**
* {@inheritdoc}
*/
protected function buildContentFiltering(Command $command, array $contains, $not = false)
{
foreach ($contains as $contain) {
$expr = Expression::create($contain);
// todo: avoid forking process for each $pattern by using multiple -e options
$command->add('| grep -v \'^$\'')->add('| xargs -I{} grep -I')->add($expr->isCaseSensitive() ? null : '-i')->add($not ? '-L' : '-l')->add('-Ee')->arg($expr->renderPattern())->add('{}');
}
}
示例3: testCastToString
public function testCastToString()
{
$cmd = Command::create();
$cmd->add('--force');
$cmd->add('--run');
$this->assertSame('--force --run', (string) $cmd);
}
示例4: buildDatesFiltering
private function buildDatesFiltering(Command $command, array $dates)
{
foreach ($dates as $i => $date) {
$command->add($i > 0 ? '-and' : null);
$mins = (int) round((time() - $date->getTarget()) / 60);
if (0 > $mins) {
$command->add(' -mmin -0');
return;
}
switch ($date->getOperator()) {
case '<=':
$command->add('-mmin +' . ($mins - 1));
break;
case '>=':
$command->add('-mmin -' . ($mins + 1));
break;
case '>':
$command->add('-mmin -' . $mins);
break;
case '!=':
$command->add('-mmin +' . $mins . ' -or -mmin -' . $mins);
break;
case '<':
default:
$command->add('-mmin +' . $mins);
}
}
}
示例5: __construct
/**
* @param AdapterInterface $adapter
* @param Command $command
* @param \Exception|null $previous
*/
public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
{
$this->command = $command;
parent::__construct($adapter, 'Shell command failed: "' . $command->join() . '".', $previous);
}
示例6: buildFormatSorting
/**
* {@inheritdoc}
*/
protected function buildFormatSorting(Command $command, $format)
{
$command->get('find')->add('-printf')->arg($format . ' %h/%f\\n')->add('| sort | cut')->arg('-d ')->arg('-f2-');
}
示例7: buildSorting
private function buildSorting(Command $command, $sort)
{
switch ($sort) {
case SortableIterator::SORT_BY_NAME:
$format = null;
break;
case SortableIterator::SORT_BY_TYPE:
$format = '%y';
break;
case SortableIterator::SORT_BY_ACCESSED_TIME:
$format = '%A@';
break;
case SortableIterator::SORT_BY_CHANGED_TIME:
$format = '%C@';
break;
case SortableIterator::SORT_BY_MODIFIED_TIME:
$format = '%T@';
break;
default:
throw new \InvalidArgumentException('Unknown sort options: '.$sort.'.');
}
$command->get('find')->add('-printf')->arg($format.' %h/%f\\n');
$command->ins('sort')->add('| sort');
$command->ins('awk')->add('| awk')->arg('{ print $'.(null === $format ? '1' : '2').' }');
}
示例8: buildSorting
/**
* @param Command $command
* @param string $sort
*
* @throws \InvalidArgumentException
*/
private function buildSorting(Command $command, $sort)
{
switch ($sort) {
case SortableIterator::SORT_BY_NAME:
$command->ins('sort')->add('| sort');
return;
case SortableIterator::SORT_BY_TYPE:
$format = '%y';
break;
case SortableIterator::SORT_BY_ACCESSED_TIME:
$format = '%A@';
break;
case SortableIterator::SORT_BY_CHANGED_TIME:
$format = '%C@';
break;
case SortableIterator::SORT_BY_MODIFIED_TIME:
$format = '%T@';
break;
default:
throw new \InvalidArgumentException('Unknown sort options: ' . $sort . '.');
}
$this->buildFormatSorting($command, $format);
}