forked from laravel/laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added vendor directory which contains the symfony console component.
- Loading branch information
1 parent
70f5862
commit c327fdc
Showing
33 changed files
with
5,649 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Console\Command; | ||
|
||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Output\Output; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
/** | ||
* HelpCommand displays the help for a given command. | ||
* | ||
* @author Fabien Potencier <[email protected]> | ||
*/ | ||
class HelpCommand extends Command | ||
{ | ||
private $command; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this->ignoreValidationErrors(); | ||
|
||
$this | ||
->setName('help') | ||
->setDefinition(array( | ||
new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), | ||
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'), | ||
)) | ||
->setDescription('Displays help for a command') | ||
->setHelp(<<<EOF | ||
The <info>%command.name%</info> command displays help for a given command: | ||
<info>php %command.full_name% list</info> | ||
You can also output the help as XML by using the <comment>--xml</comment> option: | ||
<info>php %command.full_name% --xml list</info> | ||
EOF | ||
) | ||
; | ||
} | ||
|
||
/** | ||
* Sets the command | ||
* | ||
* @param Command $command The command to set | ||
*/ | ||
public function setCommand(Command $command) | ||
{ | ||
$this->command = $command; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
if (null === $this->command) { | ||
$this->command = $this->getApplication()->get($input->getArgument('command_name')); | ||
} | ||
|
||
if ($input->getOption('xml')) { | ||
$output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW); | ||
} else { | ||
$output->writeln($this->command->asText()); | ||
} | ||
|
||
$this->command = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Console\Command; | ||
|
||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Output\Output; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputDefinition; | ||
|
||
/** | ||
* ListCommand displays the list of all available commands for the application. | ||
* | ||
* @author Fabien Potencier <[email protected]> | ||
*/ | ||
class ListCommand extends Command | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('list') | ||
->setDefinition($this->createDefinition()) | ||
->setDescription('Lists commands') | ||
->setHelp(<<<EOF | ||
The <info>%command.name%</info> command lists all commands: | ||
<info>php %command.full_name%</info> | ||
You can also display the commands for a specific namespace: | ||
<info>php %command.full_name% test</info> | ||
You can also output the information as XML by using the <comment>--xml</comment> option: | ||
<info>php %command.full_name% --xml</info> | ||
It's also possible to get raw list of commands (useful for embedding command runner): | ||
<info>php %command.full_name% --raw</info> | ||
EOF | ||
) | ||
; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getNativeDefinition() | ||
{ | ||
return $this->createDefinition(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
if ($input->getOption('xml')) { | ||
$output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), OutputInterface::OUTPUT_RAW); | ||
} else { | ||
$output->writeln($this->getApplication()->asText($input->getArgument('namespace'), $input->getOption('raw'))); | ||
} | ||
} | ||
|
||
private function createDefinition() | ||
{ | ||
return new InputDefinition(array( | ||
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), | ||
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'), | ||
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), | ||
)); | ||
} | ||
} |
192 changes: 192 additions & 0 deletions
192
vendor/Symfony/Component/Console/Formatter/OutputFormatter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Console\Formatter; | ||
|
||
/** | ||
* Formatter class for console output. | ||
* | ||
* @author Konstantin Kudryashov <[email protected]> | ||
* | ||
* @api | ||
*/ | ||
class OutputFormatter implements OutputFormatterInterface | ||
{ | ||
/** | ||
* The pattern to phrase the format. | ||
*/ | ||
const FORMAT_PATTERN = '#<([a-z][a-z0-9_=;-]+)>(.*?)</\\1?>#is'; | ||
|
||
private $decorated; | ||
private $styles = array(); | ||
|
||
/** | ||
* Initializes console output formatter. | ||
* | ||
* @param Boolean $decorated Whether this formatter should actually decorate strings | ||
* @param array $styles Array of "name => FormatterStyle" instances | ||
* | ||
* @api | ||
*/ | ||
public function __construct($decorated = null, array $styles = array()) | ||
{ | ||
$this->decorated = (Boolean) $decorated; | ||
|
||
$this->setStyle('error', new OutputFormatterStyle('white', 'red')); | ||
$this->setStyle('info', new OutputFormatterStyle('green')); | ||
$this->setStyle('comment', new OutputFormatterStyle('yellow')); | ||
$this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); | ||
|
||
foreach ($styles as $name => $style) { | ||
$this->setStyle($name, $style); | ||
} | ||
} | ||
|
||
/** | ||
* Sets the decorated flag. | ||
* | ||
* @param Boolean $decorated Whether to decorate the messages or not | ||
* | ||
* @api | ||
*/ | ||
public function setDecorated($decorated) | ||
{ | ||
$this->decorated = (Boolean) $decorated; | ||
} | ||
|
||
/** | ||
* Gets the decorated flag. | ||
* | ||
* @return Boolean true if the output will decorate messages, false otherwise | ||
* | ||
* @api | ||
*/ | ||
public function isDecorated() | ||
{ | ||
return $this->decorated; | ||
} | ||
|
||
/** | ||
* Sets a new style. | ||
* | ||
* @param string $name The style name | ||
* @param OutputFormatterStyleInterface $style The style instance | ||
* | ||
* @api | ||
*/ | ||
public function setStyle($name, OutputFormatterStyleInterface $style) | ||
{ | ||
$this->styles[strtolower($name)] = $style; | ||
} | ||
|
||
/** | ||
* Checks if output formatter has style with specified name. | ||
* | ||
* @param string $name | ||
* | ||
* @return Boolean | ||
* | ||
* @api | ||
*/ | ||
public function hasStyle($name) | ||
{ | ||
return isset($this->styles[strtolower($name)]); | ||
} | ||
|
||
/** | ||
* Gets style options from style with specified name. | ||
* | ||
* @param string $name | ||
* | ||
* @return OutputFormatterStyleInterface | ||
* | ||
* @throws \InvalidArgumentException When style isn't defined | ||
* | ||
* @api | ||
*/ | ||
public function getStyle($name) | ||
{ | ||
if (!$this->hasStyle($name)) { | ||
throw new \InvalidArgumentException('Undefined style: '.$name); | ||
} | ||
|
||
return $this->styles[strtolower($name)]; | ||
} | ||
|
||
/** | ||
* Formats a message according to the given styles. | ||
* | ||
* @param string $message The message to style | ||
* | ||
* @return string The styled message | ||
* | ||
* @api | ||
*/ | ||
public function format($message) | ||
{ | ||
return preg_replace_callback(self::FORMAT_PATTERN, array($this, 'replaceStyle'), $message); | ||
} | ||
|
||
/** | ||
* Replaces style of the output. | ||
* | ||
* @param array $match | ||
* | ||
* @return string The replaced style | ||
*/ | ||
private function replaceStyle($match) | ||
{ | ||
if (!$this->isDecorated()) { | ||
return $match[2]; | ||
} | ||
|
||
if (isset($this->styles[strtolower($match[1])])) { | ||
$style = $this->styles[strtolower($match[1])]; | ||
} else { | ||
$style = $this->createStyleFromString($match[1]); | ||
|
||
if (false === $style) { | ||
return $match[0]; | ||
} | ||
} | ||
|
||
return $style->apply($this->format($match[2])); | ||
} | ||
|
||
/** | ||
* Tries to create new style instance from string. | ||
* | ||
* @param string $string | ||
* | ||
* @return Symfony\Component\Console\Format\FormatterStyle|Boolean false if string is not format string | ||
*/ | ||
private function createStyleFromString($string) | ||
{ | ||
if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { | ||
return false; | ||
} | ||
|
||
$style = new OutputFormatterStyle(); | ||
foreach ($matches as $match) { | ||
array_shift($match); | ||
|
||
if ('fg' == $match[0]) { | ||
$style->setForeground($match[1]); | ||
} elseif ('bg' == $match[0]) { | ||
$style->setBackground($match[1]); | ||
} else { | ||
$style->setOption($match[1]); | ||
} | ||
} | ||
|
||
return $style; | ||
} | ||
} |
Oops, something went wrong.