/**
  * Add a sfCommandOption objects.
  *
  * @param sfCommandOption $option A sfCommandOption object
  */
 public function addOption(sfCommandOption $option)
 {
     if (isset($this->options[$option->getName()])) {
         throw new sfCommandException(sprintf('An option named "%s" already exist.', $option->getName()));
     } else {
         if (isset($this->shortcuts[$option->getShortcut()])) {
             throw new sfCommandException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut()));
         }
     }
     $this->options[$option->getName()] = $option;
     if ($option->getShortcut()) {
         $this->shortcuts[$option->getShortcut()] = $option->getName();
     }
 }
$t->is($option->getDefault(), 'default', '->getDefault() returns the default value');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED);
$t->ok(null === $option->getDefault(), '->getDefault() returns null if no default value is configured');
$option = new sfCommandOption('foo', null, sfCommandOption::IS_ARRAY);
$t->is($option->getDefault(), array(), '->getDefault() returns an empty array if option is an array');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE);
$t->ok($option->getDefault() === false, '->getDefault() returns false if the option does not take a parameter');
// ->setDefault()
$t->diag('->setDefault()');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED, '', 'default');
$option->setDefault(null);
$t->ok(null === $option->getDefault(), '->setDefault() can reset the default value by passing null');
$option->setDefault('another');
$t->is($option->getDefault(), 'another', '->setDefault() changes the default value');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY);
$option->setDefault(array(1, 2));
$t->is($option->getDefault(), array(1, 2), '->setDefault() changes the default value');
try {
    $option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_NONE);
    $option->setDefault('default');
    $t->fail('->setDefault() throws an sfCommandException if you give a default value for a PARAMETER_NONE option');
} catch (sfCommandException $e) {
    $t->pass('->setDefault() throws an sfCommandException if you give a default value for a PARAMETER_NONE option');
}
try {
    $option = new sfCommandOption('foo', 'f', sfCommandOption::IS_ARRAY);
    $option->setDefault('default');
    $t->fail('->setDefault() throws an sfCommandException if you give a default value which is not an array for a IS_ARRAY option');
} catch (sfCommandException $e) {
    $t->pass('->setDefault() throws an sfCommandException if you give a default value which is not an array for a IS_ARRAY option');
}
 public function setOption(sfCommandOption $option, $value)
 {
     if ($option->isArray()) {
         $this->optionValues[$option->getName()][] = $value;
     } else {
         $this->optionValues[$option->getName()] = $value;
     }
 }