Skip to content

Commit 2bf3ddc

Browse files
committed
Update readme to mention ShellPathCompletion class
1 parent 6cdee9b commit 2bf3ddc

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class MyCompletionCommand extends CompletionCommand {
5959
}
6060
```
6161

62-
**Command-specific argument completion with an array:**
62+
##### Command-specific argument completion with an array
6363

6464
```php
6565
$this->handler->addHandler(
@@ -87,7 +87,7 @@ but not this:
8787
$ myapp run [tab]
8888
```
8989

90-
**Non-command-specific (global) argument completion with a function**
90+
##### Non-command-specific (global) argument completion with a function
9191

9292
```php
9393
$this->handler->addHandler(
@@ -110,7 +110,7 @@ $ myapp walk [tab]
110110
$ myapp run [tab]
111111
```
112112

113-
**Option completion**
113+
##### Option completion
114114

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

@@ -143,8 +143,20 @@ Completion::makeGlobalHandler(
143143
)
144144
```
145145

146+
### Example: completing filesystem paths
147+
148+
This library provides the completion class `ShellPathCompletion` which defers path completion to the shell's built-in path completion behaviour rather than implementing it in PHP.
149+
150+
```php
151+
new Completion\ShellPathCompletion(
152+
Completion::ALL_COMMANDS,
153+
'path',
154+
Completion::TYPE_OPTION
155+
)
156+
157+
```
158+
146159
## Behaviour notes
147160

148161
* Option shortcuts are not offered as completion options, however requesting completion (ie. pressing tab) on a valid option shortcut will complete.
149162
* Completion is not implemented for the `--option="value"` style of passing a value to an option, however `--option value` and `--option "value"` work and are functionally identical.
150-
* There is currently no way to hand-off to BASH to complete folder/file names.

0 commit comments

Comments
 (0)