-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from t101jv/master
Fix for completer plugin crash.
- Loading branch information
Showing
1 changed file
with
26 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
|
||
### | ||
Completer plugin | ||
================ | ||
Provides tab completion. Options passed during creation are: | ||
- `shell` , (required) A reference to your shell application. | ||
### | ||
module.exports = (settings) -> | ||
# Validation | ||
throw new Error 'No shell provided' if not settings.shell | ||
shell = settings.shell | ||
# Plug completer to interface | ||
return unless shell.isShell | ||
shell.interface().completer = (text) -> | ||
suggestions = [] | ||
routes = shell.routes | ||
for route in routes | ||
command = route.command | ||
if command.substr(0, text.length) is text | ||
suggestions.push command | ||
[suggestions, text] | ||
null | ||
|
||
### | ||
Completer plugin | ||
================ | ||
Provides tab completion. Options passed during creation are: | ||
- `shell` , (required) A reference to your shell application. | ||
### | ||
module.exports = (settings) -> | ||
# Validation | ||
throw new Error 'No shell provided' if not settings.shell | ||
shell = settings.shell | ||
# Plug completer to interface | ||
return unless shell.isShell | ||
shell.interface().completer = (text, cb) -> | ||
suggestions = [] | ||
routes = shell.routes | ||
for route in routes | ||
command = route.command | ||
if command.substr(0, text.length) is text | ||
suggestions.push command | ||
cb(false, [suggestions, text]) | ||
null |