made it so aliases are now added as separate commands, no longer an array of commands - makes it easier to override aliased commands in subclasses
This commit is contained in:
parent
8394004c93
commit
ec66e9bade
|
@ -40,17 +40,18 @@ class Pry
|
|||
|
||||
arg_match = '(?:\s+(\S+))?' * 20
|
||||
if name.is_a?(Array)
|
||||
matcher = []
|
||||
name.each do |n|
|
||||
matcher << /^#{n}(?!\S)#{arg_match}?/
|
||||
matcher = /^#{n}(?!\S)#{arg_match}?/
|
||||
commands[matcher] = block
|
||||
command_info[n] = description
|
||||
end
|
||||
else
|
||||
matcher = /^#{name}(?!\S)#{arg_match}?/
|
||||
end
|
||||
|
||||
commands[matcher] = block
|
||||
command_info[name] = description
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
command "help", "This menu." do |cmd|
|
||||
out = opts[:output]
|
||||
|
@ -61,7 +62,7 @@ class Pry
|
|||
out.puts "Command list:"
|
||||
out.puts "--"
|
||||
command_info.each do |k, v|
|
||||
out.puts "#{Array(k).first}".ljust(18) + v
|
||||
out.puts "#{k}".ljust(18) + v
|
||||
end
|
||||
else
|
||||
key = command_info.keys.find { |v| Array(v).any? { |k| k === param } }
|
||||
|
|
|
@ -182,7 +182,7 @@ class Pry
|
|||
def val.clear() replace("") end
|
||||
def eval_string.clear() replace("") end
|
||||
|
||||
pattern, action = commands.commands.find { |k, v| Array(k).any? { |a| a === val } }
|
||||
pattern, action = commands.commands.find { |k, v| k === val }
|
||||
|
||||
if pattern
|
||||
captures = Regexp.last_match.captures
|
||||
|
|
Loading…
Reference in New Issue