add tab completion for filenames. works fine with real readline, only does current directory in rbreadline, see #664

git-svn-id: file:///home/svn/framework3/trunk@9357 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2010-05-24 22:57:27 +00:00
parent acf45118a2
commit a6d39ca581
2 changed files with 20 additions and 0 deletions

View File

@ -99,6 +99,23 @@ module CommandDispatcher
return items
end
#
# Provide a generic tab completion for file names.
#
# This currently works with the system readline (i.e. when msfconsole was
# invoked with -i) for everything but doesn't do more than files the
# current directory in the bundled rbreadline. In rbreadline anything with
# a / will fail to complete.
#
def tab_complete_filenames(str, words)
matches = ::Readline::FILENAME_COMPLETION_PROC.call(str)
if matches and matches.length == 1 and File.directory?(matches[0])
dir = (matches[0] + File::SEPARATOR)
matches = ::Readline::FILENAME_COMPLETION_PROC.call(dir)
end
matches
end
#
# The driver that this command dispatcher is associated with.
#

View File

@ -141,6 +141,9 @@ class Core
driver.update_prompt
end
def cmd_resource_tabs(str, words)
tab_complete_filenames(str, words)
end
def cmd_resource(*args)
if args.empty?
print(