Class: Commander::HelpFormatter::Terminal

Inherits:
Base show all
Defined in:
lib/commander/help_formatters/terminal.rb

Direct Known Subclasses

TerminalCompact

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Commander::HelpFormatter::Base

Instance Method Details

#renderObject


8
9
10
# File 'lib/commander/help_formatters/terminal.rb', line 8

def render
  template(:help).result(ProgramContext.new(@runner).get_binding)
end

#render_command(command) ⇒ Object


12
13
14
# File 'lib/commander/help_formatters/terminal.rb', line 12

def render_command(command)
  template(:command_help).result(Context.new(command).get_binding)
end

#template(name) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/commander/help_formatters/terminal.rb', line 16

def template(name)
  if RUBY_VERSION < '2.6'
    ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal', "#{name}.erb")), nil, '-')
  else
    ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal', "#{name}.erb")), trim_mode: '-')
  end
end