Skip to content

Commit

Permalink
added --debug/-d and --env/-d to console
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 7, 2011
1 parent 41bf849 commit 9f30e42
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Expand Up @@ -34,9 +34,11 @@ public function __construct(KernelInterface $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('--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();

Expand Down
32 changes: 32 additions & 0 deletions src/Symfony/Component/Console/Input/ArgvInput.php
Expand Up @@ -252,4 +252,36 @@ public function hasParameterOption($values)

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;
}
}
27 changes: 27 additions & 0 deletions src/Symfony/Component/Console/Input/ArrayInput.php
Expand Up @@ -82,6 +82,33 @@ public function hasParameterOption($values)
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.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/Console/Input/InputInterface.php
Expand Up @@ -37,6 +37,18 @@ function getFirstArgument();
*/
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.
*
Expand Down

0 comments on commit 9f30e42

Please sign in to comment.