Class: Rouge::CLI::List

Inherits:
Rouge::CLI show all
Defined in:
lib/rouge/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rouge::CLI

class_from_arg, error!, #error!, #initialize

Constructor Details

This class inherits a constructor from Rouge::CLI

Class Method Details

.descObject



447
448
449
# File 'lib/rouge/cli.rb', line 447

def self.desc
  "list available lexers"
end

.doc {|%|usage: rouge list|| ... } ⇒ Object

Yields:

  • (%|usage: rouge list|)


451
452
453
454
455
456
457
# File 'lib/rouge/cli.rb', line 451

def self.doc
  return enum_for(:doc) unless block_given?

  yield %|usage: rouge list|
  yield %||
  yield %|print a list of all available lexers with their descriptions.|
end

.parse(argv) ⇒ Object



459
460
461
# File 'lib/rouge/cli.rb', line 459

def self.parse(argv)
  new
end

Instance Method Details

#runObject



463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/rouge/cli.rb', line 463

def run
  puts "== Available Lexers =="

  Lexer.all.sort_by(&:tag).each do |lexer|
    desc = String.new("#{lexer.desc}")
    if lexer.aliases.any?
      desc << " [aliases: #{lexer.aliases.join(',')}]"
    end
    puts "%s: %s" % [lexer.tag, desc]

    lexer.option_docs.keys.sort.each do |option|
      puts "  ?#{option}= #{lexer.option_docs[option]}"
    end

    puts
  end
end