From 0158cd28f1bce0f0a61f864c424265586300529f Mon Sep 17 00:00:00 2001 From: James Lee Date: Thu, 13 Jan 2011 20:22:13 +0000 Subject: [PATCH] tab complete local filenames for upload command git-svn-id: file:///home/svn/framework3/trunk@11575 4d416f70-5f16-0410-b530-b9f4589650da --- .../console/command_dispatcher/stdapi/fs.rb | 6 ++++ lib/rex/ui/text/dispatcher_shell.rb | 32 +++++++++---------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb index b6e2f66b55..0efe76ae34 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/fs.rb @@ -428,6 +428,12 @@ class Console::CommandDispatcher::Stdapi::Fs return true end + def cmd_upload_tabs(str, words) + return [] if words.length > 1 + + tab_complete_filenames(str, words) + end + end end diff --git a/lib/rex/ui/text/dispatcher_shell.rb b/lib/rex/ui/text/dispatcher_shell.rb index 00e1e1468d..3bf0b6ec36 100644 --- a/lib/rex/ui/text/dispatcher_shell.rb +++ b/lib/rex/ui/text/dispatcher_shell.rb @@ -84,6 +84,22 @@ module DispatcherShell # attr_accessor :shell, :tab_complete_items + # + # Provide a generic tab completion for file names. + # + # If the only completion is a directory, this descends into that directory + # and continues completions with filenames contained within. + # + 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] + dir += File::SEPARATOR if dir[-1,1] != File::SEPARATOR + matches = ::Readline::FILENAME_COMPLETION_PROC.call(dir) + end + matches + end + end # @@ -206,22 +222,6 @@ module DispatcherShell return items end - # - # Provide a generic tab completion for file names. - # - # If the only completion is a directory, this descends into that directory - # and continues completions with filenames contained within. - # - 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] - dir += File::SEPARATOR if dir[-1,1] != File::SEPARATOR - matches = ::Readline::FILENAME_COMPLETION_PROC.call(dir) - end - matches - end - # # Run a single command line. #