@@ -71,7 +71,7 @@ def cmd_alias(*args)
71
71
clear = false
72
72
# if using -f or -c, they must be the first arg, because -f/-c may also show up in the alias
73
73
# value so we can't do something like if args.include("-f") or delete_if etc
74
- # we sould never have to force and clear simultaneously.
74
+ # we should never have to force and clear simultaneously.
75
75
if args [ 0 ] == "-f"
76
76
force = true
77
77
args . shift
@@ -80,7 +80,7 @@ def cmd_alias(*args)
80
80
args . shift
81
81
end
82
82
name = args . shift
83
- print_good "The alias name is #{ name } "
83
+
84
84
if clear
85
85
# clear all aliases if "*"
86
86
if name == "*"
@@ -89,9 +89,12 @@ def cmd_alias(*args)
89
89
end
90
90
print_status "Cleared all aliases"
91
91
else # clear the named alias if it exists
92
- print_status "Checking alias #{ name } for clear"
93
- deregister_alias ( name ) if @aliases . keys . include? ( name )
94
- print_status "Cleared alias #{ name } "
92
+ if @aliases . keys . include? ( name )
93
+ deregister_alias ( name )
94
+ print_status "Cleared alias #{ name } "
95
+ else
96
+ print_error ( "#{ name } is not a currently active alias" )
97
+ end
95
98
end
96
99
return
97
100
end
@@ -150,10 +153,13 @@ def register_alias(name, value)
150
153
# we need to repair the tab complete string/words and pass back
151
154
# replace alias name with the root alias value
152
155
value_words = value . split ( /[\s \t \n ]+/ ) # in case value is e.g. 'sessions -l'
156
+ # valwords is now [sessions,-l]
153
157
words [ 0 ] = value_words [ 0 ]
154
- value_words . shift
158
+ # words[0] is now 'sessions' (was 'sue')
159
+ value_words . shift # valwords is now ['-l']
155
160
# insert any remaining parts of value and rebuild the line
156
161
line = words . join ( " " ) + " " + value_words . join ( " " ) + " " + str
162
+
157
163
#print_good "passing (#{line.strip}) back to tab_complete"
158
164
# clear current tab_words
159
165
driver . tab_words = [ ]
@@ -173,11 +179,13 @@ def register_alias(name, value)
173
179
#
174
180
def deregister_alias ( name )
175
181
self . class_eval do
176
- # remove the methods we defined for this alias
182
+ # remove the class methods we created when the alias was registered
177
183
remove_method ( "cmd_#{ name } " )
178
- remove_method ( "cmd_#{ name } _tab " )
184
+ remove_method ( "cmd_#{ name } _tabs " )
179
185
remove_method ( "cmd_#{ name } _help" )
180
186
end
187
+ # remove the alias from the list of active aliases
188
+ @aliases . delete ( name )
181
189
end
182
190
183
191
#
@@ -284,13 +292,16 @@ def cleanup
284
292
# If we had previously registered a console dispatcher with the console,
285
293
# deregister it now.
286
294
remove_console_dispatcher ( 'Alias' )
295
+
296
+ # we don't need to remove class methods we added because they were added to
297
+ # AliasCommandDispatcher class
287
298
end
288
299
289
300
#
290
301
# This method returns a short, friendly name for the plugin.
291
302
#
292
303
def name
293
- "Alias "
304
+ "alias "
294
305
end
295
306
296
307
#
0 commit comments