Sha256: af7ad196c5d15962f3fc9ca534973e10966ad9137b5c99f2c794def6be8ccf13

Contents?: true

Size: 572 Bytes

Versions: 23

Compression:

Stored size: 572 Bytes

Contents

require 'erb'

module RCoLi
  
  module Help
    
    def help(*args)
      if args[0].empty?
        puts template('help', nil)
      else
        command = self
        args[0].each do |arg| 
          command = command.find_command(arg)
          raise InvalidCommand, "'#{arg}' is not a valid #{@name} command" unless command
        end
        puts template('help_command', command)
      end
    end

    def template(name, command)
      ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', "#{name}.erb")), nil, '-').result binding
    end

  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rcoli-0.7.1 lib/rcoli/help.rb
rcoli-0.7.0 lib/rcoli/help.rb
rcoli-0.6.8 lib/rcoli/help.rb
rcoli-0.6.7 lib/rcoli/help.rb
rcoli-0.6.6 lib/rcoli/help.rb
rcoli-0.6.5 lib/rcoli/help.rb
rcoli-0.6.4 lib/rcoli/help.rb
rcoli-0.6.3 lib/rcoli/help.rb
rcoli-0.6.2 lib/rcoli/help.rb
rcoli-0.6.1 lib/rcoli/help.rb
rcoli-0.6.0 lib/rcoli/help.rb
rcoli-0.5.12 lib/rcoli/help.rb
rcoli-0.5.11 lib/rcoli/help.rb
rcoli-0.5.10 lib/rcoli/help.rb
rcoli-0.5.9 lib/rcoli/help.rb
rcoli-0.5.8 lib/rcoli/help.rb
rcoli-0.5.7 lib/rcoli/help.rb
rcoli-0.5.6 lib/rcoli/help.rb
rcoli-0.5.5 lib/rcoli/help.rb
rcoli-0.5.4 lib/rcoli/help.rb