Skip to content

Commit 0af0b69

Browse files
committed
Make readme nicer
1 parent 4d9ac1b commit 0af0b69

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
# Symfony Console completion
22

3-
Automatic BASH completion for Symfony Console Component based applications. Completes commands and options by default, and allows for custom option/argument completion handlers to be set.
3+
This package provides automatic BASH completion for Symfony Console Component based applications. With minimal configuration, this package allows completion of available command names and the options they provide. Custom completion behaviour can be added for option and argument values by name.
44

5-
## Use
5+
## Basic use
66

7-
If you don't need any custom completion behaviour, just add an instance of `CompletionCommand` to your application's `Application::getDefaultCommands()` method. Once you've done this, you can run this line of BASH to enable completion:
7+
If you don't need any custom completion behaviour:
88

9-
eval `[your-application] _completion -g [program-name]`
9+
1. Install `stecman/symfony-console-completion` through composer
10+
2. Add an instance of `CompletionCommand` to your application's `Application::getDefaultCommands()`:
11+
```
12+
protected function getDefaultCommands()
13+
{
14+
...
15+
$commands[] = new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand();
16+
...
17+
}
18+
```
1019

11-
Where `[program-name]` is the name you want to register bash completion for. This will be the same as `[your-application]` if your application is in your PATH.
20+
3. Run `eval $([your-application] _completion -g [program-name])` in a terminal, where `[program-name]` is the name you want to register bash completion for (this will be the same as `[your-application]` if your application is on your PATH).
21+
4. Add the above command to your bash profile if you want the completion to apply automatically for new terminal sessions.
1222

13-
This will generate and run a small bash script which creates a small wrapper function and registers completion for your appliction name. Completion is then handled by running your application as `[your-application] _completion`.
23+
The command `_completion -g [program-name]` (`-g` being a shortcut for `--genhook`) generates a few lines of bash that, when run, register your application as a completion handler for `[program-name]`. Completion is handled by running the completion command on your application with no arguments: `[your-application] _completion`.
1424

15-
### Custom completion
25+
## Custom completion
1626

17-
Custom completion behaviour for arguments and option values can be added by sub-classing `CompletionCommand`:
27+
Custom completion behaviour for argument and option values can be added by sub-classing `CompletionCommand`.
1828

29+
The following examples are for an application with this signature: `myapp (walk|run) [-w|--weather=""] direction`
1930

2031
class MyCompletionCommand extends CompletionCommand{
2132

@@ -33,8 +44,6 @@ Custom completion behaviour for arguments and option values can be added by sub-
3344

3445
}
3546

36-
Imagine you have an application with this signature: `myapp (walk|run) [-w|--weather=""] direction`
37-
3847

3948
**Command-specific argument completion with an array:**
4049

@@ -52,7 +61,7 @@ but not this:
5261
myapp run [tab]
5362

5463

55-
**Non-command-specifc (global) argument completion with a function**
64+
**Non-command-specific (global) argument completion with a function**
5665

5766
Completion::makeGlobalHandler(
5867
'direction', Completion::TYPE_ARGUMENT,
@@ -75,7 +84,7 @@ This will complete for both commands:
7584

7685
Option handlers work the same way as argument handlers, except you use `Completion::TYPE_OPTION` for the type.
7786

78-
**Note this functionality is not yet complete:** long-form options (eg `--hello="world"`) do not support completion yet. Only option shortcut completion works (eg. `-h [tab]`).
87+
**Note this functionality is not yet complete:** long-form options (eg `--hello="world"`) do not support completion yet. Option completion is only supported for shortcuts (eg. `-h [tab]`).
7988

8089
Completion::makeGlobalHandler(
8190
'weather', Completion::TYPE_OPTION,
@@ -88,4 +97,4 @@ Option completion is only supported for shortcuts currently:
8897

8998
## Notes
9099

91-
Option shorcuts are not offered as completion options, however requesting completion (ie. pressing tab) on a valid option shortcut will complete.
100+
* Option shorcuts are not offered as completion options, however requesting completion (ie. pressing tab) on a valid option shortcut will complete.

0 commit comments

Comments
 (0)