added --debug/-d and --env/-d to console
This commit is contained in:
parent
41bf849a63
commit
9f30e42c16
@ -34,9 +34,11 @@ class Application extends BaseApplication
|
|||||||
{
|
{
|
||||||
$this->kernel = $kernel;
|
$this->kernel = $kernel;
|
||||||
|
|
||||||
parent::__construct('Symfony', Kernel::VERSION.' - '.$kernel->getName());
|
parent::__construct('Symfony', Kernel::VERSION.' - '.$kernel->getName().'/'.$kernel->getEnvironment().($kernel->isDebug() ? '/debug' : ''));
|
||||||
|
|
||||||
$this->definition->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
|
$this->definition->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
|
||||||
|
$this->definition->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev'));
|
||||||
|
$this->definition->addOption(new InputOption('--debug', '-d', InputOption::VALUE_NONE, 'Whether to run in debug mode.'));
|
||||||
|
|
||||||
$this->kernel->boot();
|
$this->kernel->boot();
|
||||||
|
|
||||||
|
@ -252,4 +252,36 @@ class ArgvInput extends Input
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a raw option (not parsed).
|
||||||
|
*
|
||||||
|
* This method is to be used to introspect the input parameters
|
||||||
|
* before it has been validated. It must be used carefully.
|
||||||
|
*
|
||||||
|
* @param string|array $values The value(s) to look for in the raw parameters (can be an array)
|
||||||
|
*
|
||||||
|
* @return mixed The option value
|
||||||
|
*/
|
||||||
|
public function getParameterOption(array $values, $default = false)
|
||||||
|
{
|
||||||
|
if (!is_array($values)) {
|
||||||
|
$values = array($values);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tokens = $this->tokens;
|
||||||
|
while ($token = array_shift($tokens)) {
|
||||||
|
foreach ($values as $value) {
|
||||||
|
if (0 === strpos($token, $value)) {
|
||||||
|
if (false !== $pos = strpos($token, '=')) {
|
||||||
|
return substr($token, $pos + 1);
|
||||||
|
} else {
|
||||||
|
return array_shift($this->tokens);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,33 @@ class ArrayInput extends Input
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a raw option (not parsed).
|
||||||
|
*
|
||||||
|
* This method is to be used to introspect the input parameters
|
||||||
|
* before it has been validated. It must be used carefully.
|
||||||
|
*
|
||||||
|
* @param string|array $values The value(s) to look for in the raw parameters (can be an array)
|
||||||
|
*
|
||||||
|
* @return mixed The option value
|
||||||
|
*/
|
||||||
|
public function getParameterOption(array $values, $default = false)
|
||||||
|
{
|
||||||
|
if (!is_array($values)) {
|
||||||
|
$values = array($values);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->parameters as $k => $v) {
|
||||||
|
if (is_int($k) && in_array($v, $values)) {
|
||||||
|
return true;
|
||||||
|
} elseif (in_array($k, $values)) {
|
||||||
|
return $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes command line arguments.
|
* Processes command line arguments.
|
||||||
*/
|
*/
|
||||||
|
@ -37,6 +37,18 @@ interface InputInterface
|
|||||||
*/
|
*/
|
||||||
function hasParameterOption($value);
|
function hasParameterOption($value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of a raw option (not parsed).
|
||||||
|
*
|
||||||
|
* This method is to be used to introspect the input parameters
|
||||||
|
* before it has been validated. It must be used carefully.
|
||||||
|
*
|
||||||
|
* @param string|array $values The value(s) to look for in the raw parameters (can be an array)
|
||||||
|
*
|
||||||
|
* @return mixed The option value
|
||||||
|
*/
|
||||||
|
function getParameterOption(array $values, $default = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds the current Input instance with the given arguments and options.
|
* Binds the current Input instance with the given arguments and options.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user