Skip to content

Commit 436b72d

Browse files
committed
Land rapid7#9023, Add tab completion to the edit command
2 parents 14308fb + 27dcc16 commit 436b72d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/msf/ui/console/command_dispatcher/modules.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Modules
2626
def commands
2727
{
2828
"back" => "Move back from the current context",
29-
"edit" => "Edit the current module with the preferred editor",
29+
"edit" => "Edit the current module or a file with the preferred editor",
3030
"advanced" => "Displays advanced options for one or more modules",
3131
"info" => "Displays information about one or more modules",
3232
"options" => "Displays global options or for one or more modules",
@@ -67,14 +67,14 @@ def local_editor
6767
def cmd_edit_help
6868
print_line "Usage: edit [file/to/edit.rb]"
6969
print_line
70-
print_line "Edit a local file or the currently active module with #{local_editor}"
71-
print_line "If a file path is specified it will automatically be reloaded after editing"
70+
print_line "Edit the currently active module or a local file with #{local_editor}."
71+
print_line "If a file path is specified, it will automatically be reloaded after editing."
7272
print_line "Otherwise, you can reload the active module with 'reload' or 'rerun'."
7373
print_line
7474
end
7575

7676
#
77-
# Edit the currently active module
77+
# Edit the currently active module or a local file
7878
#
7979
def cmd_edit(*args)
8080
if args.length > 0
@@ -85,22 +85,32 @@ def cmd_edit(*args)
8585

8686
if path
8787
editor = local_editor
88+
8889
if editor.nil?
8990
editor = 'vim'
9091
print_warning("LocalEditor or $VISUAL/$EDITOR should be set. Falling back on #{editor}.")
9192
end
9293

9394
print_status("Launching #{editor} #{path}")
9495
system(editor, path)
95-
96+
97+
# XXX: This will try to reload *anything* and break on modules
9698
if args.length > 0
97-
load args[0]
99+
print_status("Reloading #{path}")
100+
load path
98101
end
99102
else
100103
print_error('Nothing to edit -- try using a module first.')
101104
end
102105
end
103106

107+
#
108+
# Tab completion for the edit command
109+
#
110+
def cmd_edit_tabs(str, words)
111+
tab_complete_filenames(str, words)
112+
end
113+
104114
def cmd_advanced_help
105115
print_line 'Usage: advanced [mod1 mod2 ...]'
106116
print_line

0 commit comments

Comments
 (0)