# File lib/earthquake/input.rb, line 54 def command(pattern, options = {}, &block) if block if pattern.is_a?(String) || pattern.is_a?(Symbol) command_name = ":#{pattern}" command_names << command_name if block.arity > 0 pattern = %r|^#{command_name}\s+(.*)$| else pattern = %r|^#{command_name}$| end end command_names << ":#{options[:as]}" if options[:as] commands << {:pattern => pattern, :block => block} else commands.detect {|c| c[:pattern] =~ pattern} end end