Skip to content

Commit 4953fda

Browse files
author
kernelsmith
committed
fixed -c problems, plugin name, some tab_compl issues remain
1 parent 90081b1 commit 4953fda

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

plugins/alias.rb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def cmd_alias(*args)
7171
clear = false
7272
# if using -f or -c, they must be the first arg, because -f/-c may also show up in the alias
7373
# 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.
7575
if args[0] == "-f"
7676
force = true
7777
args.shift
@@ -80,7 +80,7 @@ def cmd_alias(*args)
8080
args.shift
8181
end
8282
name = args.shift
83-
print_good "The alias name is #{name}"
83+
8484
if clear
8585
# clear all aliases if "*"
8686
if name == "*"
@@ -89,9 +89,12 @@ def cmd_alias(*args)
8989
end
9090
print_status "Cleared all aliases"
9191
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
9598
end
9699
return
97100
end
@@ -150,10 +153,13 @@ def register_alias(name, value)
150153
# we need to repair the tab complete string/words and pass back
151154
# replace alias name with the root alias value
152155
value_words = value.split(/[\s\t\n]+/) # in case value is e.g. 'sessions -l'
156+
# valwords is now [sessions,-l]
153157
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']
155160
# insert any remaining parts of value and rebuild the line
156161
line = words.join(" ") + " " + value_words.join(" ") + " " + str
162+
157163
#print_good "passing (#{line.strip}) back to tab_complete"
158164
# clear current tab_words
159165
driver.tab_words = []
@@ -173,11 +179,13 @@ def register_alias(name, value)
173179
#
174180
def deregister_alias(name)
175181
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
177183
remove_method("cmd_#{name}")
178-
remove_method("cmd_#{name}_tab")
184+
remove_method("cmd_#{name}_tabs")
179185
remove_method("cmd_#{name}_help")
180186
end
187+
# remove the alias from the list of active aliases
188+
@aliases.delete(name)
181189
end
182190

183191
#
@@ -284,13 +292,16 @@ def cleanup
284292
# If we had previously registered a console dispatcher with the console,
285293
# deregister it now.
286294
remove_console_dispatcher('Alias')
295+
296+
# we don't need to remove class methods we added because they were added to
297+
# AliasCommandDispatcher class
287298
end
288299

289300
#
290301
# This method returns a short, friendly name for the plugin.
291302
#
292303
def name
293-
"Alias"
304+
"alias"
294305
end
295306

296307
#

0 commit comments

Comments
 (0)