Split tab completion into separate methods for each sub-command
This commit is contained in:
+17
-7
@@ -96,10 +96,9 @@ class Plugin::HashCapture < Msf::Plugin
|
||||
end
|
||||
end
|
||||
|
||||
def cmd_capture_tabs(str, words)
|
||||
return ['start', 'stop'] if words.length == 1
|
||||
if words[1] == 'start'
|
||||
case words[-1]
|
||||
def tab_complete_start(str, words)
|
||||
last_word = words[-1]
|
||||
case last_word
|
||||
when '--session'
|
||||
return framework.sessions.keys.map { |k| k.to_s }
|
||||
when '--cert', '--configfile', '--logfile'
|
||||
@@ -111,15 +110,19 @@ class Plugin::HashCapture < Msf::Plugin
|
||||
|
||||
end
|
||||
|
||||
if @@start_opt_parser.arg_required?(words[-1])
|
||||
if @@start_opt_parser.arg_required?(last_word)
|
||||
# The previous word needs an argument; we can't provide any help
|
||||
return []
|
||||
end
|
||||
|
||||
# Otherwise, we are expecting another flag next
|
||||
result = @@start_opt_parser.option_keys.select { |opt| opt.start_with?(str) }
|
||||
return result
|
||||
elsif words[1] == 'stop'
|
||||
case words[-1]
|
||||
end
|
||||
|
||||
def tab_complete_stop(str, words)
|
||||
last_word = words[-1]
|
||||
case last_word
|
||||
when '--session'
|
||||
return framework.sessions.keys.map { |k| k.to_s } + ['local']
|
||||
end
|
||||
@@ -129,7 +132,14 @@ class Plugin::HashCapture < Msf::Plugin
|
||||
end
|
||||
|
||||
result = @@stop_opt_parser.option_keys.select { |opt| opt.start_with?(str) }
|
||||
end
|
||||
|
||||
def cmd_capture_tabs(str, words)
|
||||
return ['start', 'stop'] if words.length == 1
|
||||
if words[1] == 'start'
|
||||
tab_complete_start(str, words)
|
||||
elsif words[1] == 'stop'
|
||||
tab_complete_stop(str, words)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user