@@ -26,7 +26,7 @@ class Modules
26
26
def commands
27
27
{
28
28
"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" ,
30
30
"advanced" => "Displays advanced options for one or more modules" ,
31
31
"info" => "Displays information about one or more modules" ,
32
32
"options" => "Displays global options or for one or more modules" ,
@@ -67,14 +67,14 @@ def local_editor
67
67
def cmd_edit_help
68
68
print_line "Usage: edit [file/to/edit.rb]"
69
69
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. "
72
72
print_line "Otherwise, you can reload the active module with 'reload' or 'rerun'."
73
73
print_line
74
74
end
75
75
76
76
#
77
- # Edit the currently active module
77
+ # Edit the currently active module or a local file
78
78
#
79
79
def cmd_edit ( *args )
80
80
if args . length > 0
@@ -85,22 +85,32 @@ def cmd_edit(*args)
85
85
86
86
if path
87
87
editor = local_editor
88
+
88
89
if editor . nil?
89
90
editor = 'vim'
90
91
print_warning ( "LocalEditor or $VISUAL/$EDITOR should be set. Falling back on #{ editor } ." )
91
92
end
92
93
93
94
print_status ( "Launching #{ editor } #{ path } " )
94
95
system ( editor , path )
95
-
96
+
97
+ # XXX: This will try to reload *anything* and break on modules
96
98
if args . length > 0
97
- load args [ 0 ]
99
+ print_status ( "Reloading #{ path } " )
100
+ load path
98
101
end
99
102
else
100
103
print_error ( 'Nothing to edit -- try using a module first.' )
101
104
end
102
105
end
103
106
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
+
104
114
def cmd_advanced_help
105
115
print_line 'Usage: advanced [mod1 mod2 ...]'
106
116
print_line
0 commit comments