本文整理汇总了PHP中Illuminate\Console\Command::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::run方法的具体用法?PHP Command::run怎么用?PHP Command::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Console\Command
的用法示例。
在下文中一共展示了Command::run方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Override run method to internationalize error message.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int Return code
*/
public function run(InputInterface $input, OutputInterface $output)
{
// Set extra colors
// The most problem is $output->getFormatter() don't work.
// So create new formatter to add extra color.
$formatter = new OutputFormatter($output->isDecorated());
$formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
$formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
$formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
$formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
$formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
$formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
$output->setFormatter($formatter);
\App::setLocale(\Config::get('syncle::MessageLang'));
try {
$result = parent::run($input, $output);
} catch (\RuntimeException $e) {
// All error messages were hard coded in
// Symfony/Component/Console/Input/Input.php
if ($e->getMessage() == 'Not enough arguments.') {
$this->error(\Lang::get('syncle::BaseCommand.ArgumentNotEnough'));
} elseif ($e->getMessage() == 'Too many arguments.') {
$this->error(\Lang::get('syncle::BaseCommand.TooManyArgument'));
} elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
$this->error(\Lang::get('syncle::BaseCommand.OptionNotExist', array('option' => $matches[1])));
} else {
$this->error($e->getMessage());
}
$result = 1;
}
return $result;
}
示例2: run
public function run(InputInterface $input, OutputInterface $output)
{
// Set extra colors.
// The most problem is $output->getFormatter() don't work...
// So create new formatter to add extra color.
$formatter = new OutputFormatter($output->isDecorated());
$formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
$formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
$formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
$formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
$formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
$formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
$output->setFormatter($formatter);
return parent::run($input, $output);
}
示例3: run
/**
* Symfonyコマンドコンポーネントにハードコードされている
* エラーメッセージを日本語に変換する.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return int Return code
*/
public function run(InputInterface $input, OutputInterface $output)
{
try {
$result = parent::run($input, $output);
} catch (\RuntimeException $e) {
if ($e->getMessage() == 'Not enough arguments.') {
throw new \RuntimeException(__('引数が足りません。'), $e->getCode(), $e->getPrevious());
} elseif ($e->getMessage() == 'Too many arguments.') {
throw new \RuntimeException(__('引数が多すぎます。'), $e->getCode(), $e->getPrevious());
} elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
throw new \RuntimeException(__($matches[1] . 'オプションは存在していません。'), $e->getCode(), $e->getPrevious());
} else {
throw new \RuntimeException($e->getMessage(), $e->getCode(), $e->getPrevious());
}
}
return $result;
}
示例4: run
/**
* Override run method to internationalize error message.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int Return code
*/
public function run(InputInterface $input, OutputInterface $output)
{
try {
$result = parent::run($input, $output);
} catch (\RuntimeException $e) {
// All error messages were hard coded in
// Symfony/Component/Console/Input/Input.php
if ($e->getMessage() == 'Not enough arguments.') {
$this->error(\Lang::get('StriveJobs::BaseCommand.ArgumentNotEnough'));
} elseif ($e->getMessage() == 'Too many arguments.') {
$this->error(\Lang::get('StriveJobs::BaseCommand.TooManyArgument'));
} elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
$this->error(\Lang::get('StriveJobs::BaseCommand.OptionNotExist', array('option' => $matches[1])));
} else {
$this->error($e->getMessage());
}
$result = 1;
// As error status code
}
return $result;
}
示例5: runCommand
protected function runCommand(Command $command, array $input, OutputInterface $output)
{
$command->setLaravel($this->app);
return $command->run(new ArrayInput($input), $output);
}
示例6: run
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return int
*/
public function run(InputInterface $input, OutputInterface $output)
{
app(ConsoleOutput::class)->setOutput($this);
return parent::run($input, $output);
}
示例7: runCommand
/**
* Run the command.
* @param \Illuminate\Console\Command $command
* @param array $input
* @return int
*/
protected function runCommand($command, $input = [])
{
return $command->run(new ArrayInput($input), new NullOutput());
}
示例8: run
/**
* run.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return \Symfony\Component\Console\Input\StringInput
*/
public function run(InputInterface $input, OutputInterface $output)
{
$command = (string) $input;
$command = strtr($command, [' -name' => ' -N', ' -type' => ' -T', ' -maxdepth' => ' -M', ' -delete' => ' -d true']);
return parent::run(new StringInput($command), $output);
}
示例9: invokeCommand
/**
* @param \Illuminate\Console\Command $mockedCommandObject
* @param array $arguments
* @return int
*/
public function invokeCommand(Command $mockedCommandObject, $arguments = [])
{
$mockedCommandObject->setLaravel(app());
return $mockedCommandObject->run(new ArrayInput($arguments), $this->getCommandOutput());
}
示例10: run
public function run(InputInterface $input, OutputInterface $output)
{
$options = $input->__toString();
$arr = explode(' ', $options);
array_shift($arr);
foreach ($arr as $i => &$option) {
$option = trim($option, "'");
if (strpos($option, '-') === 0) {
$option = '{' . $option . '?}';
} else {
$option = '{k' . $i . '}';
}
}
$this->signature = implode(' ', $arr);
$this->configureUsingFluentDefinition();
$this->setDescription($this->description);
return parent::run($input, $output);
}