Hi
I want to have two options which are mutual exclusive. This works fine:
$inputOption = $input->registerOption(
new ezcConsoleOption(
'i',
'input',
ezcConsoleInput::TYPE_STRING
)
);
$outputOption = $input->registerOption(
new ezcConsoleOption(
'o',
'output'
)
);
$outputOption->type = ezcConsoleInput::TYPE_STRING;
$inputOption->addExclusion( new ezcConsoleOptionRule( $outputOption ) );
$outputOption->addExclusion( new ezcConsoleOptionRule( $inputOption ) );
But this doesn't work if you don't want to have short parameters like -i and -o (only --input and --output). There is nothing in the documentation saying this is not possible. On the contrary, http://ezcomponents.org/docs/api/trunk/ConsoleTools/ezcConsoleOption.html
ezcConsoleOption __construct( [string $short = ''], string $long (...) )
However, if you let $short='', the example above will not work:
$inputOption = $input->registerOption(
new ezcConsoleOption(
'',
'input',
ezcConsoleInput::TYPE_STRING
)
);
$outputOption = $input->registerOption(
new ezcConsoleOption(
'',
'output'
)
);
$outputOption->type = ezcConsoleInput::TYPE_STRING;
$inputOption->addExclusion( new ezcConsoleOptionRule( $outputOption ) );
$outputOption->addExclusion( new ezcConsoleOptionRule( $inputOption ) );
The output will then be:
$ php a.php -input asd
The option 'input' excludes the option 'output'but this one was submitted.
(also note the lack of space before "but")
PS
My example is based on example 6 on http://ezcomponents.org/docs/tutorials/ConsoleTools#mastering-options-and-arguments