Skip to content

Commit 4a00c44

Browse files
committed
update readme
1 parent da0773a commit 4a00c44

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ then this functionality is already integrated with it.
2727
$ gem install completely
2828
```
2929

30+
or with homebrew:
31+
32+
```bash
33+
$ brew install brew-gem
34+
$ brew gem install completely
35+
````
36+
3037
## Using the `completely` command line
3138

3239
The `completely` command line works with a simple YAML configuration file as
@@ -159,6 +166,37 @@ mygit:
159166
The `2> /dev/null` is used so that if the command is executed in a directory
160167
without a git repository, it will still behave as expected.
161168

169+
### Suggesting flag arguments
170+
171+
Adding a `*` wildcard in the middle of a pattern can be useful for suggesting
172+
arguments for flags. For example:
173+
174+
```yaml
175+
mygit checkout:
176+
- --branch
177+
- -b
178+
179+
mygit checkout*--branch:
180+
- $(git branch 2> /dev/null)
181+
182+
mygit checkout*-b:
183+
- $(git branch 2> /dev/null)
184+
```
185+
186+
The above will suggest git branches for commands that end with `-b` or `--branch`.
187+
To avoid code duplication, you may use YAML aliases, so the above can also be
188+
written like this:
189+
190+
```yaml
191+
mygit checkout:
192+
- --branch
193+
- -b
194+
195+
mygit checkout*--branch: &branches
196+
- $(git branch 2> /dev/null)
197+
198+
mygit checkout*-b: *branches
199+
```
162200

163201
## Using the generated completion scripts
164202

@@ -171,6 +209,18 @@ $ source completely.bash
171209
You may wish to add this to your `~/.bashrc` file to enable this for future
172210
sessions (just be sure to use absolute path).
173211

212+
## Testing and debugging completions scripts
213+
214+
You can use the built in completions script tester by running `completely test`.
215+
216+
This command lets you test any completions script, whether it was generated by
217+
completely or not.
218+
219+
In addition, you can set the `COMPLETELY_DEBUG` environment variable to any value
220+
in order to generate scripts with some additional debugging functionality. Run
221+
`completely generate --help` for additional information.
222+
223+
174224
## Using from within Ruby code
175225

176226
```ruby
@@ -192,6 +242,9 @@ puts completions.script
192242
# Or, generate a function that echos the script
193243
puts completions.wrapper_function
194244
puts completions.wrapper_function "custom_function_name"
245+
246+
# Or, test the completions with the Tester object
247+
p completions.tester.test "mygit status "
195248
```
196249

197250

0 commit comments

Comments
 (0)