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

@ -5,7 +5,7 @@ Initialize Symfony Console commands from annotated command class methods.
[![Travis CI](https://travis-ci.org/consolidation/annotated-command.svg?branch=master)](https://travis-ci.org/consolidation/annotated-command)
[![Windows CI](https://ci.appveyor.com/api/projects/status/c2c4lcf43ux4c30p?svg=true)](https://ci.appveyor.com/project/greg-1-anderson/annotated-command)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/consolidation/annotated-command/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/consolidation/annotated-command/?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/consolidation/annotated-command/badge.svg?branch=master)](https://coveralls.io/github/consolidation/annotated-command?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/consolidation/annotated-command/badge.svg?branch=master)](https://coveralls.io/github/consolidation/annotated-command?branch=master)
[![License](https://poser.pugx.org/consolidation/annotated-command/license)](https://packagist.org/packages/consolidation/annotated-command)
## Component Status
@ -31,7 +31,7 @@ This library provides routines to produce the Symfony\Component\Console\Command\
This is a library intended to be used in some other project. Require from your composer.json file:
```
"require": {
"consolidation/annotated-command": "~2"
"consolidation/annotated-command": "^2"
},
```
@ -43,12 +43,12 @@ The rest of the parameters are arguments. Parameters with a default value are op
class MyCommandClass
{
/**
* This is the my:cat command
* This is the my:echo command
*
* This command will concatenate two parameters. If the --flip flag
* is provided, then the result is the concatenation of two and one.
*
* @command my:cat
* @command my:echo
* @param integer $one The first parameter.
* @param integer $two The other parameter.
* @option arr An option that takes multiple values.
@ -57,7 +57,7 @@ class MyCommandClass
* @usage bet alpha --flip
* Concatenate "alpha" and "bet".
*/
public function myCat($one, $two, $options = ['flip' => false])
public function myEcho($one, $two, $options = ['flip' => false])
{
if ($options['flip']) {
return "{$two}{$one}";
@ -65,7 +65,7 @@ class MyCommandClass
return "{$one}{$two}";
}
}
```
```
## Option Default Values
The `$options` array must be an associative array whose key is the name of the option, and whose value is one of:
@ -103,6 +103,7 @@ The hook **target** specifies which command or commands the hook will be attache
- The command's primary name (e.g. `my:command`) or the command's method name (e.g. myCommand) will attach the hook to only that command.
- An annotation (e.g. `@foo`) will attach the hook to any command that is annotated with the given label.
- If the target is specified as `*`, then the hook will be attached to all commands.
- If the target is omitted, then the hook will be attached to every command defined in the same class as the hook implementation.
There are ten types of hooks in the command processing request flow:
@ -143,7 +144,7 @@ There are ten types of hooks in the command processing request flow:
- @status
- [Extract](#extract-hook)
- @extract
In addition to these, there are two more hooks available:
- [On-event](#on-event-hook)
@ -201,6 +202,42 @@ public function initSomeCommand(InputInterface $input, AnnotationData $annotatio
}
```
You may alter the AnnotationData here by using simple array syntax. Below, we
add an additional display field label for a Property List.
```
use Consolidation\AnnotatedCommand\AnnotationData;
use Symfony\Component\Console\Input\InputInterface;
/**
* @hook init some:command
*/
public function initSomeCommand(InputInterface $input, AnnotationData $annotationData)
{
$annotationData['field-labels'] .= "\n" . "new_field: My new field";
}
```
Alternately, you may use the `set()` or `append()` methods on the AnnotationData
class.
```
use Consolidation\AnnotatedCommand\AnnotationData;
use Symfony\Component\Console\Input\InputInterface;
/**
* @hook init some:command
*/
public function initSomeCommand(InputInterface $input, AnnotationData $annotationData)
{
// Add a line to the field labels.
$annotationData->append('field-labels', "\n" . "new_field: My new field");
// Replace all field labels.
$annotationData->set('field-labels', "one_field: My only field");
}
```
### Interact Hook
The interact hook ([InteractorInterface](src/Hooks/InteractorInterface.php)) runs prior to argument and option validation. Required arguments and options not supplied on the command line may be provided during this phase by prompting the user. Note that the interact hook is not called if the --no-interaction flag is supplied, whereas the command-event hook and the init hook are.
@ -407,8 +444,8 @@ class MyReplaceCommandHook {
/**
* @hook replace-command foo:bar
*
* Parameters must match original command method.
*
* Parameters must match original command method.
*/
public function myFooBarReplacement($value) {
print "Hello $value!";
@ -432,6 +469,46 @@ If you want to use annotations, but still want access to the Symfony Command, e.
It is also possible to add InputInterface and/or OutputInterface parameters to any annotated method of a command file (the parameters must go before command arguments).
## Parameter Injection
Just as this library will by default inject $input and/or $output at the head of the parameter list of any command function, it is also possible to add a handler to inject other objects as well.
Given an implementation of SymfonyStyleInjector similar to the example below:
```
use Consolidation\AnnotatedCommand\ParameterInjector
class SymfonyStyleInjector implements ParameterInjector
{
public function get(CommandData $commandData, $interfaceName)
{
return new MySymfonyStyle($commandData->input(), $commandData->output());
}
}
```
Then, an instance of 'MySymfonyStyle' will be provided to any command handler method that takes a SymfonyStyle parameter if the SymfonyStyleInjector is registered in your application's initialization code like so:
```
$commandProcessor->parameterInjection()->register('Symfony\Component\Console\Style\SymfonyStyle', new SymfonyStyleInjector);
```
## Handling Standard Input
Any Symfony command may use the provides StdinHandler to imlement commands that read from standard input.
```php
/**
* @command example
* @option string $file
* @default $file -
*/
public function example(InputInterface $input)
{
$data = StdinHandler::selectStream($input, 'file')->contents();
}
```
This example will read all of the data available from the stdin stream into $data, or, alternately, will read the entire contents of the file specified via the `--file=/path` option.
For more details, including examples of using the StdinHandle with a DI container, see the comments in [StdinHandler.php](src/Input/StdinHandler.php).
## API Usage
If you would like to use Annotated Commands to build a commandline tool, it is recommended that you use [Robo as a framework](http://robo.li/framework), as it will set up all of the various command classes for you. If you would like to integrate Annotated Commands into some other framework, see the sections below.
@ -504,7 +581,7 @@ Listeners can be used to construct command file instances as they are provided t
### Option Providers
An option provider is given an opportunity to add options to a command as it is being constructed.
An option provider is given an opportunity to add options to a command as it is being constructed.
```
public function AnnotatedCommandFactory::addAutomaticOptionProvider(AutomaticOptionsProviderInterface $listener);
```
@ -516,7 +593,3 @@ CommandInfo alterers can adjust information about a command immediately before i
```
public function alterCommandInfo(CommandInfo $commandInfo, $commandFileInstance);
```
## Comparison to Existing Solutions
The existing solutions used their own hand-rolled regex-based parsers to process the contents of the DocBlock comments. consolidation/annotated-command uses the [phpdocumentor/reflection-docblock](https://github.com/phpDocumentor/ReflectionDocBlock) project (which is itself a regex-based parser) to interpret DocBlock contents.