composer update

This commit is contained in:
Oliver Davies 2019-01-24 08:00:03 +00:00
parent f6abc3dce2
commit 71dfaca858
1753 changed files with 45274 additions and 14619 deletions

View file

@ -59,7 +59,7 @@ If you don't need any custom completion behaviour, you can simply add the comple
eval $([program] _completion --generate-hook)
```
By default this registers completion for the absolute path to you application, which will work if the program on accessible on your PATH. You can specify a program name to complete for instead using the `--program` option, which is required if you're using an alias to run the program.
By default this registers completion for the absolute path to you application, which will work if the program is accessible on your PATH. You can specify a program name to complete for instead using the `--program` option, which is required if you're using an alias to run the program.
4. If you want the completion to apply automatically for all new shell sessions, add the command from step 3 to your shell's profile (eg. `~/.bash_profile` or `~/.zshrc`)
@ -206,7 +206,7 @@ To have a completion run for both options and arguments matching the specified n
$handler->addHandler(
new Completion(
Completion::ALL_COMMANDS,
'pacakge',
'package',
Completion::ALL_TYPES,
function() {
// ...

View file

@ -10,7 +10,6 @@ use Symfony\Component\Console\Output\OutputInterface;
class CompletionCommand extends SymfonyCommand
{
/**
* @var CompletionHandler
*/
@ -49,6 +48,52 @@ END
return $this->createDefinition();
}
/**
* Ignore user-defined global options
*
* Any global options defined by user-code are meaningless to this command.
* Options outside of the core defaults are ignored to avoid name and shortcut conflicts.
*/
public function mergeApplicationDefinition($mergeArgs = true)
{
// Get current application options
$appDefinition = $this->getApplication()->getDefinition();
$originalOptions = $appDefinition->getOptions();
// Temporarily replace application options with a filtered list
$appDefinition->setOptions(
$this->filterApplicationOptions($originalOptions)
);
parent::mergeApplicationDefinition($mergeArgs);
// Restore original application options
$appDefinition->setOptions($originalOptions);
}
/**
* Reduce the passed list of options to the core defaults (if they exist)
*
* @param InputOption[] $appOptions
* @return InputOption[]
*/
protected function filterApplicationOptions(array $appOptions)
{
return array_filter($appOptions, function(InputOption $option) {
static $coreOptions = array(
'help' => true,
'quiet' => true,
'verbose' => true,
'version' => true,
'ansi' => true,
'no-ansi' => true,
'no-interaction' => true,
);
return isset($coreOptions[$option->getName()]);
});
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->handler = new CompletionHandler($this->getApplication());

View file

@ -0,0 +1,41 @@
<?php
namespace Stecman\Component\Symfony\Console\BashCompletion\Tests;
use PHPUnit\Framework\TestCase;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;
class CompletionCommandTest extends TestCase
{
/**
* Ensure conflicting options names and shortcuts from the application do not break the completion command
*/
public function testConflictingGlobalOptions()
{
$app = new Application('Base application');
// Conflicting option shortcut
$app->getDefinition()->addOption(
new InputOption('conflicting-shortcut', 'g', InputOption::VALUE_NONE)
);
// Conflicting option name
$app->getDefinition()->addOption(
new InputOption('program', null, InputOption::VALUE_REQUIRED)
);
$app->add(new CompletionCommand());
// Check completion command doesn't throw
$app->doRun(new StringInput('_completion -g --program foo'), new NullOutput());
$app->doRun(new StringInput('_completion --help'), new NullOutput());
$app->doRun(new StringInput('help _completion'), new NullOutput());
// Check default options are available
$app->doRun(new StringInput('_completion -V -vv --no-ansi --quiet'), new NullOutput());
}
}