Class: Commander::HelpFormatter::Terminal
- Defined in:
- lib/commander/help_formatters/terminal.rb
Overview
The default help formatter. Renders full-width, verbosely-labeled
help text (examples, per-option descriptions, etc.) from the ERB
templates in the neighboring terminal/ directory. See
HelpFormatter::TerminalCompact for a more condensed alternative.
Direct Known Subclasses
Instance Method Summary collapse
-
#render ⇒ Object
Render the global help text for the program.
-
#render_command(command) ⇒ Object
Render the help text for a single command.
-
#template(name) ⇒ Object
Compile the ERB template named name (+:help+ or
:command_help) from this formatter's template directory.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Commander::HelpFormatter::Base
Instance Method Details
#render ⇒ Object
Render the global help text for the program.
15 16 17 |
# File 'lib/commander/help_formatters/terminal.rb', line 15 def render template(:help).result(ProgramContext.new(@runner).get_binding) end |
#render_command(command) ⇒ Object
Render the help text for a single command.
21 22 23 |
# File 'lib/commander/help_formatters/terminal.rb', line 21 def render_command(command) template(:command_help).result(Context.new(command).get_binding) end |
#template(name) ⇒ Object
Compile the ERB template named name (+:help+ or
:command_help) from this formatter's template directory.
28 29 30 |
# File 'lib/commander/help_formatters/terminal.rb', line 28 def template(name) ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal', "#{name}.erb")), trim_mode: '-') end |