class Pry::CommandSet
def alias_command(match, action, options = {})
- Example: Pass explicit description (overriding default). -
Example: Creating an alias for `ls -M` -
Parameters:
-
options
(Hash
) -- The optional configuration parameters, -
action
(String
) -- The action to be performed (typically -
match
(String, Regex
) -- The match of the alias (can be a regex).
def alias_command(match, action, options = {}) (cmd = find_command(action)) || raise("command: '#{action}' not found") original_options = cmd.options.dup options = original_options.merge!( desc: "Alias for `#{action}`", listing: match.is_a?(String) ? match : match.inspect ).merge!(options) # ensure default description is used if desc is nil desc = options.delete(:desc).to_s c = block_command match, desc, options do |*args| run action, *args end # TODO: untested. What's this about? c.class_eval do define_method(:complete) do |input| cmd.new(context).complete(input) end end c.group "Aliases" c end