added --debug/-d and --env/-d to console

This commit is contained in:
Fabien Potencier 2011-02-07 03:03:02 +01:00
parent 41bf849a63
commit 9f30e42c16
4 changed files with 74 additions and 1 deletions

View File

@ -34,9 +34,11 @@ class Application extends BaseApplication
{
$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('--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();

View File

@ -252,4 +252,36 @@ class ArgvInput extends Input
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;
}
}

View File

@ -82,6 +82,33 @@ class ArrayInput extends Input
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.
*/

View File

@ -37,6 +37,18 @@ interface InputInterface
*/
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.
*