def_builtin_commands(delegation_class, command_specs)
public
CommandProcessor.def_builtin_commands(delegation_class, command_specs)
delegation_class: Class or Module
command_specs: [[command_name, [argument,...]],...]
command_name: String
arguments: String
FILENAME?? -> expand_path(filename??)
*FILENAME?? -> filename??.collect{|f|expand_path(f)}.join(", ")
define command_name(argument,...) as
delegation_class.command_name(argument,...)
Show source
def self.def_builtin_commands(delegation_class, command_specs)
for meth, args in command_specs
arg_str = args.collect{|arg| arg.downcase}.join(", ")
call_arg_str = args.collect{
|arg|
case arg
when /^(FILENAME.*)$/
format("expand_path(%s)", $1.downcase)
when /^(\*FILENAME.*)$/
$1.downcase + '.collect{|fn| expand_path(fn)}'
else
arg
end
}.join(", ")
d = %Q[def #{meth}(#{arg_str})
#{delegation_class}.#{meth}(#{call_arg_str})
end]
Shell.notify "Define #{meth}(#{arg_str})", Shell.debug?
Shell.notify("Definition of #{meth}: ", d,
Shell.debug.kind_of?(Integer) && Shell.debug > 1)
eval d
end
end