Skip to content

Commit

Permalink
[CLI] renamed Argument to InputArgument, Option to InputOption, and D…
Browse files Browse the repository at this point in the history
…efinition to InputDefinition
  • Loading branch information
fabpot committed Jan 8, 2010
1 parent 71156a4 commit 41bc39b
Show file tree
Hide file tree
Showing 19 changed files with 288 additions and 290 deletions.
26 changes: 13 additions & 13 deletions src/Symfony/Components/CLI/Application.php
Expand Up @@ -5,9 +5,9 @@
use Symfony\Components\CLI\Input\InputInterface;
use Symfony\Components\CLI\Input\ArgvInput;
use Symfony\Components\CLI\Input\ArrayInput;
use Symfony\Components\CLI\Input\Definition;
use Symfony\Components\CLI\Input\Option;
use Symfony\Components\CLI\Input\Argument;
use Symfony\Components\CLI\Input\InputDefinition;
use Symfony\Components\CLI\Input\InputOption;
use Symfony\Components\CLI\Input\InputArgument;
use Symfony\Components\CLI\Output\OutputInterface;
use Symfony\Components\CLI\Output\Output;
use Symfony\Components\CLI\Output\ConsoleOutput;
Expand Down Expand Up @@ -72,15 +72,15 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
$this->addCommand(new HelpCommand());
$this->addCommand(new ListCommand());

$this->definition = new Definition(array(
new Argument('command', Argument::REQUIRED, 'The command to execute'),
$this->definition = new InputDefinition(array(
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),

new Option('--help', '-h', Option::PARAMETER_NONE, 'Display this help message.'),
new Option('--quiet', '-q', Option::PARAMETER_NONE, 'Do not output any message.'),
new Option('--verbose', '-v', Option::PARAMETER_NONE, 'Increase verbosity of messages.'),
new Option('--version', '-V', Option::PARAMETER_NONE, 'Display this program version.'),
new Option('--color', '-c', Option::PARAMETER_NONE, 'Force ANSI color output.'),
new Option('--no-interaction', '-n', Option::PARAMETER_NONE, 'Do not ask any interactive question.'),
new InputOption('--help', '-h', InputOption::PARAMETER_NONE, 'Display this help message.'),
new InputOption('--quiet', '-q', InputOption::PARAMETER_NONE, 'Do not output any message.'),
new InputOption('--verbose', '-v', InputOption::PARAMETER_NONE, 'Increase verbosity of messages.'),
new InputOption('--version', '-V', InputOption::PARAMETER_NONE, 'Display this program version.'),
new InputOption('--color', '-c', InputOption::PARAMETER_NONE, 'Force ANSI color output.'),
new InputOption('--no-interaction', '-n', InputOption::PARAMETER_NONE, 'Do not ask any interactive question.'),
));
}

Expand Down Expand Up @@ -201,9 +201,9 @@ public function doRun(InputInterface $input, OutputInterface $output)
}

/**
* Gets the Definition related to this Application.
* Gets the InputDefinition related to this Application.
*
* @return Definition The Definition instance
* @return InputDefinition The InputDefinition instance
*/
public function getDefinition()
{
Expand Down
18 changes: 9 additions & 9 deletions src/Symfony/Components/CLI/Command/Command.php
Expand Up @@ -2,9 +2,9 @@

namespace Symfony\Components\CLI\Command;

use Symfony\Components\CLI\Input\Definition;
use Symfony\Components\CLI\Input\Option;
use Symfony\Components\CLI\Input\Argument;
use Symfony\Components\CLI\Input\InputDefinition;
use Symfony\Components\CLI\Input\InputOption;
use Symfony\Components\CLI\Input\InputArgument;
use Symfony\Components\CLI\Input\InputInterface;
use Symfony\Components\CLI\Output\OutputInterface;
use Symfony\Components\CLI\Output\Formatter;
Expand Down Expand Up @@ -45,7 +45,7 @@ class Command
*/
public function __construct($name = null)
{
$this->definition = new Definition();
$this->definition = new InputDefinition();
$this->ignoreValidationErrors = false;
$this->applicationDefinitionMerged = false;
$this->formatter = new Formatter();
Expand Down Expand Up @@ -182,7 +182,7 @@ protected function mergeApplicationDefinition()
*/
public function setDefinition($definition)
{
if ($definition instanceof Definition)
if ($definition instanceof InputDefinition)
{
$this->definition = $definition;
}
Expand All @@ -200,15 +200,15 @@ public function setDefinition($definition)
* Adds an argument.
*
* @param string $name The argument name
* @param integer $mode The argument mode: Argument::REQUIRED or Argument::OPTIONAL
* @param integer $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
* @param string $description A description text
* @param mixed $default The default value (for Argument::OPTIONAL mode only)
* @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
*
* @return Command The current instance
*/
public function addArgument($name, $mode = null, $description = '', $default = null)
{
$this->definition->addArgument(new Argument($name, $mode, $description, $default));
$this->definition->addArgument(new InputArgument($name, $mode, $description, $default));

return $this;
}
Expand All @@ -226,7 +226,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n
*/
public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
{
$this->definition->addOption(new Option($name, $shortcut, $mode, $description, $default));
$this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));

return $this;
}
Expand Down
9 changes: 4 additions & 5 deletions src/Symfony/Components/CLI/Command/HelpCommand.php
Expand Up @@ -2,9 +2,8 @@

namespace Symfony\Components\CLI\Command;

use Symfony\Components\CLI\Input\Definition;
use Symfony\Components\CLI\Input\Argument;
use Symfony\Components\CLI\Input\Option;
use Symfony\Components\CLI\Input\InputArgument;
use Symfony\Components\CLI\Input\InputOption;
use Symfony\Components\CLI\Input\InputInterface;
use Symfony\Components\CLI\Output\OutputInterface;
use Symfony\Components\CLI\Output\Output;
Expand Down Expand Up @@ -39,8 +38,8 @@ protected function configure()

$this
->setDefinition(array(
new Argument('command_name', Argument::OPTIONAL, 'The command name', 'help'),
new Option('xml', null, Option::PARAMETER_NONE, 'To output help as XML'),
new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
new InputOption('xml', null, InputOption::PARAMETER_NONE, 'To output help as XML'),
))
->setName('help')
->setDescription('Displays help for a command')
Expand Down
9 changes: 4 additions & 5 deletions src/Symfony/Components/CLI/Command/ListCommand.php
Expand Up @@ -2,9 +2,8 @@

namespace Symfony\Components\CLI\Command;

use Symfony\Components\CLI\Input\Definition;
use Symfony\Components\CLI\Input\Argument;
use Symfony\Components\CLI\Input\Option;
use Symfony\Components\CLI\Input\InputArgument;
use Symfony\Components\CLI\Input\InputOption;
use Symfony\Components\CLI\Input\InputInterface;
use Symfony\Components\CLI\Output\OutputInterface;
use Symfony\Components\CLI\Output\Output;
Expand Down Expand Up @@ -35,8 +34,8 @@ protected function configure()
{
$this
->setDefinition(array(
new Argument('namespace', Argument::OPTIONAL, 'The namespace name'),
new Option('xml', null, Option::PARAMETER_NONE, 'To output help as XML'),
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
new InputOption('xml', null, InputOption::PARAMETER_NONE, 'To output help as XML'),
))
->setName('list')
->setDescription('Lists commands')
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Components/CLI/Input/ArgvInput.php
Expand Up @@ -47,9 +47,9 @@ class ArgvInput extends Input
* Constructor.
*
* @param array $argv An array of parameters from the CLI (in the argv format)
* @param Definition $definition A Definition instance
* @param InputDefinition $definition A InputDefinition instance
*/
public function __construct(array $argv = null, Definition $definition = null)
public function __construct(array $argv = null, InputDefinition $definition = null)
{
if (null === $argv)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Components/CLI/Input/ArrayInput.php
Expand Up @@ -30,9 +30,9 @@ class ArrayInput extends Input
* Constructor.
*
* @param array $param An array of parameters
* @param Definition $definition A Definition instance
* @param InputDefinition $definition A InputDefinition instance
*/
public function __construct(array $parameters, Definition $definition = null)
public function __construct(array $parameters, InputDefinition $definition = null)
{
$this->parameters = $parameters;

Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Components/CLI/Input/Input.php
Expand Up @@ -34,13 +34,13 @@ abstract class Input implements InputInterface
/**
* Constructor.
*
* @param Definition $definition A Definition instance
* @param InputDefinition $definition A InputDefinition instance
*/
public function __construct(Definition $definition = null)
public function __construct(InputDefinition $definition = null)
{
if (null === $definition)
{
$this->definition = new Definition();
$this->definition = new InputDefinition();
}
else
{
Expand All @@ -52,9 +52,9 @@ public function __construct(Definition $definition = null)
/**
* Binds the current Input instance with the given arguments and options.
*
* @param Definition $definition A Definition instance
* @param InputDefinition $definition A InputDefinition instance
*/
public function bind(Definition $definition)
public function bind(InputDefinition $definition)
{
$this->arguments = array();
$this->options = array();
Expand Down
Expand Up @@ -18,7 +18,7 @@
* @subpackage cli
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class Argument
class InputArgument
{
const REQUIRED = 1;
const OPTIONAL = 2;
Expand Down

0 comments on commit 41bc39b

Please sign in to comment.