Skip to content

Commit

Permalink
Merge pull request #9 from t101jv/master
Browse files Browse the repository at this point in the history
Fix for completer plugin crash.
  • Loading branch information
Worms David committed Jul 20, 2012
2 parents f682452 + d1ae714 commit 136f286
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions lib/plugins/completer.coffee
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

0 comments on commit 136f286

Please sign in to comment.