Skip to content

Commit

Permalink
grepo.coffee now completes both -n and -l
Browse files Browse the repository at this point in the history
  • Loading branch information
superbobry committed Jul 30, 2011
1 parent f920968 commit 64a242b
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions apps/grepo_base/static/coffee/grepo.coffee
Expand Up @@ -24,14 +24,30 @@ grepo.match = (language) ->

grepo.complete = (event, term) ->
if event.keyCode is 9 # Try to auto-complete on TAB.
options = grepo.parse term.get_command()
command = term.get_command()
[command..., key, value] = command.split /\s+/

if options? and options.language?
# a) auto-complete language
if not options.keywords.length
term.set_command "grepo -l #{grepo.match options.language} "
if key[0] isnt "-"
command.push key

# seems like we have a -fBAR case.
if value[0] is "-"
[key, value] = [value.substring(0, 2), value.substring(2)]
# okay, complete keyword
else
# query the server for the closest matching tag.
return

# complete an argument.
switch key
when "-n"
value = parseInt(value or "10", 10) * 2
when "-l"
value = grepo.match(value)

command.push key
command.push value
term.set_command command.join(" ")

return no

Expand Down

0 comments on commit 64a242b

Please sign in to comment.