tab-completion: added support for tab completion

This commit is contained in:
rkiel
2015-06-06 10:58:51 -04:00
parent 99f47b01f6
commit 59d5a0f77c
2 changed files with 39 additions and 0 deletions

32
lib/feature/tab.rb Normal file
View File

@@ -0,0 +1,32 @@
require_relative './base'
module Feature
class Tab < Feature::Base
def valid?
argv.size > 0
end
def help
puts
puts "USAGE: feature tab [pattern]"
puts
exit
end
def execute
if argv.size == 1
pattern = '.+'
else
pattern = "^#{argv[1]}"
end
regexp = Regexp.new(pattern)
cmds = Feature::Commander.tab_completion
cmds = cmds.select { |x| regexp.match(x) }
puts cmds.join("\n")
end
end
end