Skip to content

Commit 5a58357

Browse files
committed
Merge pull request #77 from AlexeyKosov/master
Resolves #76
2 parents 8b1d65f + c5a2379 commit 5a58357

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

README.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,43 @@ If you don't need any custom completion behaviour, you can simply add the comple
2323
$ composer require stecman/symfony-console-completion
2424
```
2525

26-
2. Add an instance of `CompletionCommand` to your application's `Application::getDefaultCommands()` method:
26+
2. For standalone Symfony Console applications, add an instance of `CompletionCommand` to your application's `Application::getDefaultCommands()` method:
27+
28+
```php
29+
protected function getDefaultCommands()
30+
{
31+
//...
32+
$commands[] = new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand();
33+
//...
34+
}
35+
```
36+
37+
For Symfony Framework applications, register the `CompletionCommand` as a service in `app/config/services.yml`:
2738

28-
```php
29-
protected function getDefaultCommands()
30-
{
31-
//...
32-
$commands[] = new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand();
33-
//...
34-
}
35-
```
39+
```yaml
40+
services:
41+
#...
42+
console.completion_command:
43+
class: Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand
44+
tags:
45+
- { name: console.command }
46+
#...
47+
```
3648

3749
3. Register completion for your application by running one of the following in a terminal, replacing `[program]` with the command you use to run your application (eg. 'composer'):
3850

39-
```bash
40-
# BASH ~4.x, ZSH
41-
source <([program] _completion --generate-hook)
51+
```bash
52+
# BASH ~4.x, ZSH
53+
source <([program] _completion --generate-hook)
4254

43-
# BASH ~3.x, ZSH
44-
[program] _completion --generate-hook | source /dev/stdin
55+
# BASH ~3.x, ZSH
56+
[program] _completion --generate-hook | source /dev/stdin
4557

46-
# BASH (any version)
47-
eval $([program] _completion --generate-hook)
48-
```
58+
# BASH (any version)
59+
eval $([program] _completion --generate-hook)
60+
```
4961

50-
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.
62+
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.
5163

5264
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`)
5365

@@ -71,7 +83,7 @@ By default, no completion results will be returned for option and argument value
7183
class MyCommand extends Command implements CompletionAwareInterface
7284
{
7385
...
74-
86+
7587
public function completeOptionValues($optionName, CompletionContext $context)
7688
{
7789
if ($optionName == 'some-option') {

0 commit comments

Comments
 (0)